当前位置: 首页>>代码示例>>PHP>>正文


PHP Twig_Template::getAttribute方法代码示例

本文整理汇总了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);
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:22,代码来源:BaseTemplate.php

示例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;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:17,代码来源:TwigTemplate13.php

示例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);
 }
开发者ID:aivavic,项目名称:yii2,代码行数:15,代码来源:Template.php

示例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;
 }
开发者ID:nervetattoo,项目名称:li3_twig,代码行数:16,代码来源:Template.php

示例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;
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:20,代码来源:Template.php

示例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);
 }
开发者ID:LiGhT1EsS,项目名称:yii2,代码行数:21,代码来源:Template.php

示例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;
 }
开发者ID:bombayworks,项目名称:currycms,代码行数:29,代码来源:Template.php

示例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);
     }
 }
开发者ID:HeroesOfZoltan,项目名称:wishr,代码行数:8,代码来源:TemplateTest.php

示例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);
 }
开发者ID:vebnz,项目名称:lifelitup,代码行数:4,代码来源:TemplateTest.php

示例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);
 }
开发者ID:kuslahne,项目名称:rapid-slim-php-blog-application,代码行数:4,代码来源:TemplateTest.php

示例11: getAttribute

 public function getAttribute($object, $item, array $arguments = array(), $type = Twig_Node_Expression_GetAttr::TYPE_ANY)
 {
     return parent::getAttribute($object, $item, $arguments, $type);
 }
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:4,代码来源:TemplateTest.php

示例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);
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:4,代码来源:TemplateTest.php


注:本文中的Twig_Template::getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。