mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 22:32:40 +08:00
Support for method calls on models from Twig templates
This commit is contained in:
committed by
Alexander Makarov
parent
80178e6dee
commit
fd5e05b1cf
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user