Commit fd5e05b1 by Alexei Tenitski Committed by Alexander Makarov

Support for method calls on models from Twig templates

parent 80178e6d
......@@ -19,7 +19,11 @@ abstract class Template extends \Twig_Template
// Twig uses isset() to check if attribute exists which does not work when attribute exists but is null
if ($object instanceof \yii\db\BaseActiveRecord) {
return $object->$item;
if ($type == \Twig_Template::METHOD_CALL) {
return $object->$item();
} else {
return $object->$item;
}
}
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