當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。