Skip to content

Commit e0b2b67

Browse files
authored
make compatible with twig 3.9, twig_get_attribute is now internal func (#441)
1 parent 4c25664 commit e0b2b67

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Node/GetAttrNode.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Twig\Compiler;
1111
use Twig\Environment;
1212
use Twig\Error\RuntimeError;
13+
use Twig\Extension\CoreExtension;
1314
use Twig\Extension\SandboxExtension;
1415
use Twig\Node\Expression\GetAttrExpression;
1516
use Twig\Node\Node;
@@ -144,6 +145,12 @@ public static function attribute(
144145
return $object->$item;
145146
}
146147

148+
// Note: Since twig:3.9 the 'twig_get_attribute' function was renamed to CoreExtension::getAttribute.
149+
// Because this is an internal function of twig, the authors could break it in a minor version.
150+
if (!function_exists('twig_get_attribute')) {
151+
return CoreExtension::getAttribute($env, $source, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
152+
}
153+
147154
return \twig_get_attribute(
148155
$env,
149156
$source,

0 commit comments

Comments
 (0)