From c7e4acdfb3d55a055508b9d3cc8cf71c00329e90 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 3 Jul 2020 10:55:51 +0200 Subject: [PATCH] Revert "Closes #388 (#398)" (#400) This reverts commit 3b2068aeacc094f94191ff0c47fa6ea8aaa98075. --- src/Node/GetAttrNode.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Node/GetAttrNode.php b/src/Node/GetAttrNode.php index ac0ca4c8..82d2ea15 100644 --- a/src/Node/GetAttrNode.php +++ b/src/Node/GetAttrNode.php @@ -7,7 +7,6 @@ */ namespace TwigBridge\Node; -use ArrayAccess; use Twig\Compiler; use Twig\Environment; use Twig\Error\RuntimeError; @@ -130,12 +129,7 @@ public static function attribute( $sandboxed = false, int $lineno = -1 ) { - // Twig doesn't support sandboxing on objects that implement ArrayAccess - // https://github.com/twigphp/Twig/issues/106#issuecomment-583737 - // https://github.com/twigphp/Twig/pull/1863 - // - // https://github.com/twigphp/Twig/issues/2878 - if (Template::METHOD_CALL !== $type and $object instanceof ArrayAccess) { + if (Template::METHOD_CALL !== $type and is_a($object, 'Illuminate\Database\Eloquent\Model')) { // We can't easily find out if an attribute actually exists, so return true if ($isDefinedTest) { return true; @@ -145,7 +139,7 @@ public static function attribute( $env->getExtension(SandboxExtension::class)->checkPropertyAllowed($object, $item); } - // Call the attribute, the object does the rest of the magic + // Call the attribute, the Model object does the rest of the magic return $object->$item; }