Skip to content

Commit

Permalink
Revert "Closes #388 (#398)" (#400)
Browse files Browse the repository at this point in the history
This reverts commit 3b2068a.
  • Loading branch information
barryvdh committed Jul 3, 2020
1 parent cabe086 commit c7e4acd
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Node/GetAttrNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/
namespace TwigBridge\Node;

use ArrayAccess;
use Twig\Compiler;
use Twig\Environment;
use Twig\Error\RuntimeError;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit c7e4acd

Please sign in to comment.