Commit fd5e05b1 by Alexei Tenitski Committed by Alexander Makarov

Support for method calls on models from Twig templates

parent 80178e6d
...@@ -19,8 +19,12 @@ abstract class Template extends \Twig_Template ...@@ -19,8 +19,12 @@ abstract class Template extends \Twig_Template
// Twig uses isset() to check if attribute exists which does not work when attribute exists but is null // Twig uses isset() to check if attribute exists which does not work when attribute exists but is null
if ($object instanceof \yii\db\BaseActiveRecord) { if ($object instanceof \yii\db\BaseActiveRecord) {
if ($type == \Twig_Template::METHOD_CALL) {
return $object->$item();
} else {
return $object->$item; return $object->$item;
} }
}
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck); return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment