本文整理汇总了PHP中Twig_Template::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Template::getAttribute方法的具体用法?PHP Twig_Template::getAttribute怎么用?PHP Twig_Template::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Template
的用法示例。
在下文中一共展示了Twig_Template::getAttribute方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAttribute
/**
* Returns the attribute value for a given array/object.
*
* @param mixed $object The object or array from where to get the item
* @param mixed $item The item to get from the array or object
* @param array $arguments An array of arguments to pass if the item is an object method
* @param string $type The type of attribute (@see \Twig_Template constants)
* @param bool $isDefinedTest Whether this is only a defined check
* @param bool $ignoreStrictCheck Whether to ignore the strict attribute check or not
*
* @throws \Twig_Error_Runtime If the attribute does not exist and Twig is running in strict mode and $isDefinedTest
* is false
* @return mixed The attribute value, or a bool when $isDefinedTest is true, or null when the
* attribute is not set and $ignoreStrictCheck is true
*/
protected function getAttribute($object, $item, array $arguments = array(), $type = \Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
{
if (is_object($object) && $object instanceof BaseElementModel) {
$this->_includeElementInTemplateCaches($object);
}
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
}
示例2: getAttribute
/**
* @param $object
* @param $item
* @param array $arguments
* @param string $type
* @param bool $isDefinedTest
*
* @return mixed
*/
protected function getAttribute($object, $item, array $arguments = array(), $type = \Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false)
{
$attribute = parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest);
if (self::$recorder && is_object($object)) {
self::$recorder->add($object);
}
return $attribute;
}
示例3: getAttribute
/**
* @inheritdoc
*/
protected function getAttribute($object, $item, array $arguments = [], $type = \Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
{
// 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 ($type === \Twig_Template::METHOD_CALL) {
return $object->{$item}($arguments);
} else {
return $object->{$item};
}
}
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
}
示例4: getAttribute
/**
* Override the getAttribute to handle lazy loaded li3 helpers
*/
protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $noStrictCheck = false, $line = -1)
{
$result = parent::getAttribute($object, $item, $arguments, $type, $noStrictCheck, $line);
if (is_null($result)) {
// Fetch the helper object and return it
try {
$result = is_object($object) ? $object->helper($item) : null;
} catch (\Exception $e) {
$result = null;
}
}
return $result;
}
示例5: getAttribute
/**
* Override the getAttribute to handle lazy loaded li3 helpers
*/
protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $noStrictCheck = false, $line = -1)
{
$result = parent::getAttribute($object, $item, $arguments, $type, $noStrictCheck, $line);
if ($result === null) {
// Fetch the helper object and return it
try {
if (preg_match('|Model|', get_parent_class($object)) || preg_match('|Model|', get_parent_class(get_parent_class($object)))) {
return $object->{$item};
} else {
$result = is_object($object) ? $object->helper($item) : null;
}
} catch (\Exception $e) {
$result = null;
}
}
return $result;
}
示例6: getAttribute
/**
* @inheritdoc
*/
protected function getAttribute($object, $item, array $arguments = [], $type = \Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
{
// Twig uses isset() to check if attribute exists which does not work when attribute exists but is null
if ($object instanceof \yii\base\Model) {
if ($type === \Twig_Template::METHOD_CALL) {
if ($this->env->hasExtension('sandbox')) {
$this->env->getExtension('sandbox')->checkMethodAllowed($object, $item);
}
return call_user_func_array([$object, $item], $arguments);
} else {
if ($this->env->hasExtension('sandbox')) {
$this->env->getExtension('sandbox')->checkPropertyAllowed($object, $item);
}
return $object->{$item};
}
}
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
}
示例7: getAttribute
/**
* {@inheritdoc}
*
* Additianally, currycms automatically wraps ModelCriteria-objects in
* Curry_Twig_QueryWrapper objects, and automatically calls the toTwig()
* function if it exists.
*
* @see Curry_Twig_QueryWrapper
*/
protected function getAttribute($object, $item, array $arguments = array(), $type = \Twig_TemplateInterface::ANY_CALL, $noStrictCheck = false, $line = -1)
{
if (is_object($object) && method_exists($object, '__get') && isset($object->{$item})) {
$attr = $object->{$item};
} else {
$attr = parent::getAttribute($object, $item, $arguments, $type, $noStrictCheck, $line);
}
while (is_object($attr)) {
if (method_exists($attr, 'toTwig')) {
$attr = $attr->toTwig();
} else {
if ($attr instanceof \ModelCriteria) {
$attr = new \Curry_Twig_QueryWrapper($attr);
} else {
break;
}
}
}
return $attr;
}
示例8: getAttribute
public function getAttribute($object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
{
if ($this->useExtGetAttribute) {
return twig_template_get_attributes($this, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
} else {
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
}
}
示例9: getAttribute
public function getAttribute($object, $item, array $arguments = array(), $type = Twig_Node_Expression_GetAttr::TYPE_ANY, $noStrictCheck = false, $lineno = -1)
{
return parent::getAttribute($object, $item, $arguments, $type);
}
示例10: getAttribute
public function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false)
{
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest);
}
示例11: getAttribute
public function getAttribute($object, $item, array $arguments = array(), $type = Twig_Node_Expression_GetAttr::TYPE_ANY)
{
return parent::getAttribute($object, $item, $arguments, $type);
}
示例12: getAttribute
public function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $noStrictCheck = false, $lineno = -1)
{
return parent::getAttribute($object, $item, $arguments, $type);
}