yii\twig\Template - Yii2 类参考手册

Class yii\twig\Template

Inheritanceyii\twig\Template

Template helper

Public Methods

隐藏继承的方法 Hide inherited methods

方法 Method简介 Description定义在 Defined By
attribute() Returns the attribute value for a given array/object. yii\twig\Template

方法详情 Method Details

attribute() public static method

Returns the attribute value for a given array/object.

public static mixed attribute ( \Twig\Environment $env, \Twig\Source $source, $object, $item, array $arguments = [], \yii\twig\string $type = \Twig\Template::ANY_CALL, \yii\twig\bool $isDefinedTest false, \yii\twig\bool $ignoreStrictCheck false )
$env \Twig\Environment
$source \Twig\Source
$object mixed

The object or array from where to get the item

$item mixed

The item to get from the array or object

$arguments array

An array of arguments to pass if the item is an object method

$type string

The type of attribute (@see Twig_Template constants)

$isDefinedTest boolean

Whether this is only a defined check

$ignoreStrictCheck boolean

Whether to ignore the strict attribute check or not

return mixed

The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true

throws \Twig\Error\RuntimeError

if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false