當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Twig_NodeInterface::setAttribute方法代碼示例

本文整理匯總了PHP中Twig_NodeInterface::setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_NodeInterface::setAttribute方法的具體用法?PHP Twig_NodeInterface::setAttribute怎麽用?PHP Twig_NodeInterface::setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Twig_NodeInterface的用法示例。


在下文中一共展示了Twig_NodeInterface::setAttribute方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: leaveNode

 /**
  * {@inheritdoc}
  */
 public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     if ($node instanceof \Twig_Node_Module) {
         $node->setAttribute(self::CONTEXT_REGIONS, $this->regions);
         $node->setAttribute(self::CONTEXT_INCLUDES, $this->includes);
         $module = new ContentRegionModule($node);
         $this->includes = [];
         $this->regions = [];
         return $module;
     }
     return $node;
 }
開發者ID:umber-io,項目名稱:content-region,代碼行數:15,代碼來源:ContentRegionNodeVisitor.php

示例2: __construct

 public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
 {
     if ($node instanceof Twig_Node_Expression_Name) {
         $node->setAttribute('is_defined_test', true);
     } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
         $node->setAttribute('is_defined_test', true);
         $this->changeIgnoreStrictCheck($node);
     } elseif ($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array) {
         $node = new Twig_Node_Expression_Constant(true, $node->getLine());
     } else {
         throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getLine());
     }
     parent::__construct($node, $name, $arguments, $lineno);
 }
開發者ID:mat33470,項目名稱:PFA,代碼行數:14,代碼來源:Defined.php

示例3: __construct

 public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
 {
     parent::__construct(array('node' => $node, 'arguments' => $arguments), array('name' => $name), $lineno);
     // defined is a special case
     if ('defined' === $name) {
         if ($node instanceof Twig_Node_Expression_Name) {
             $node->setAttribute('is_defined_test', true);
         } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
             $node->setAttribute('is_defined_test', true);
             $this->changeIgnoreStrictCheck($node);
         } else {
             throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine());
         }
     }
 }
開發者ID:bigjoevtrj,項目名稱:codeigniter-bootstrap,代碼行數:15,代碼來源:Test.php

示例4: enterOptimizeFor

 /**
  * Optimizes "for" tag by removing the "loop" variable creation whenever possible.
  *
  * @param Twig_NodeInterface $node A Node
  * @param Twig_Environment   $env  The current Twig environment
  */
 protected function enterOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_For) {
         // disable the loop variable by default
         $node->setAttribute('with_loop', false);
         array_unshift($this->loops, $node);
         array_unshift($this->loopsTargets, $node->getNode('value_target')->getAttribute('name'));
         array_unshift($this->loopsTargets, $node->getNode('key_target')->getAttribute('name'));
     } elseif (!$this->loops) {
         // we are outside a loop
         return;
     } elseif ($node instanceof Twig_Node_Expression_Name && 'loop' === $node->getAttribute('name')) {
         $node->setAttribute('always_defined', true);
         $this->addLoopToCurrent();
     } elseif ($node instanceof Twig_Node_Expression_Name && in_array($node->getAttribute('name'), $this->loopsTargets)) {
         $node->setAttribute('always_defined', true);
     } elseif ($node instanceof Twig_Node_BlockReference || $node instanceof Twig_Node_Expression_BlockReference) {
         $this->addLoopToCurrent();
     } elseif ($node instanceof Twig_Node_Include && !$node->getAttribute('only')) {
         $this->addLoopToAll();
     } elseif ($node instanceof Twig_Node_Expression_Function && 'include' === $node->getAttribute('name') && (!$node->getNode('arguments')->hasNode('with_context') || false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value'))) {
         $this->addLoopToAll();
     } elseif ($node instanceof Twig_Node_Expression_GetAttr && (!$node->getNode('attribute') instanceof Twig_Node_Expression_Constant || 'parent' === $node->getNode('attribute')->getAttribute('value')) && (true === $this->loops[0]->getAttribute('with_loop') || $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' === $node->getNode('node')->getAttribute('name'))) {
         $this->addLoopToAll();
     }
 }
開發者ID:betes-curieuses-design,項目名稱:ElieJosiePhotographie,代碼行數:32,代碼來源:Optimizer.php

示例5: enterNode

 /**
  * Called before child nodes are visited.
  *
  * @param \Twig_NodeInterface $node The node to visit
  * @param \Twig_Environment $env  The Twig environment instance
  *
  * @return Twig_NodeInterface The modified node
  */
 public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     if ($node instanceof \Twig_Node_Expression_Filter) {
         $name = $node->getNode('filter')->getAttribute('value');
         if ('trans' === $name) {
             $node->setAttribute('file', $this->file->getRelativePathname());
             $this->stack = $this->dataExtractor->collectDataFromTransFilterNode($node);
         }
     }
     if ($node instanceof \Twig_Node_Set) {
         $this->dataExtractor->addSetCollection($node);
     }
     if ($node instanceof \Twig_Node_For) {
         $this->dataExtractor->addForCollection($node);
     }
     return $node;
 }
開發者ID:selmanouni,項目名稱:blue-lines,代碼行數:25,代碼來源:TwigFileExtractor.php

示例6: enterOptimizeFor

 /**
  * Optimizes "for" tag by removing the "loop" variable creation whenever possible.
  *
  * @param Twig_NodeInterface $node A Node
  * @param Twig_Environment   $env  The current Twig environment
  */
 protected function enterOptimizeFor($node, $env)
 {
     if ($node instanceof Twig_Node_For) {
         // disable the loop variable by default
         $node->setAttribute('with_loop', false);
         array_unshift($this->loops, $node);
     } elseif (!$this->loops) {
         // we are outside a loop
         return;
     } elseif ($node instanceof Twig_Node_Expression_Name && 'loop' === $node->getAttribute('name')) {
         $this->addLoopToCurrent();
     } elseif ($node instanceof Twig_Node_Include && !$node->getAttribute('only')) {
         $this->addLoopToAll();
     } elseif ($node instanceof Twig_Node_Expression_GetAttr && (!$node->getNode('attribute') instanceof Twig_Node_Expression_Constant || 'parent' === $node->getNode('attribute')->getAttribute('value')) && (true === $this->loops[0]->getAttribute('with_loop') || $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' === $node->getNode('node')->getAttribute('name'))) {
         $this->addLoopToAll();
     }
 }
開發者ID:hirocaster,項目名稱:symfony-sandbox,代碼行數:23,代碼來源:Optimizer.php

示例7: enterNode

 public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Expression_GetAttr) {
         $node->setAttribute('disable_c_ext', true);
     }
     return $node;
 }
開發者ID:HeroesOfZoltan,項目名稱:wishr,代碼行數:7,代碼來源:TemplateTest.php

示例8: enterOptimizeFor

    /**
     * Optimizes "for" tag by removing the "loop" variable creation whenever possible.
     *
     * @param Twig_NodeInterface $node A Node
     * @param Twig_Environment   $env  The current Twig environment
     */
    protected function enterOptimizeFor($node, $env)
    {
        if ($node instanceof Twig_Node_For) {
            // disable the loop variable by default
            $node->setAttribute('with_loop', false);
            array_unshift($this->loops, $node);
        } elseif (!$this->loops) {
            // we are outside a loop
            return;
        }

        // when do we need to add the loop variable back?

        // the loop variable is referenced for the current loop
        elseif ($node instanceof Twig_Node_Expression_Name && 'loop' === $node->getAttribute('name')) {
            $this->addLoopToCurrent();
        }

        // block reference
        elseif ($node instanceof Twig_Node_BlockReference || $node instanceof Twig_Node_Expression_BlockReference) {
            $this->addLoopToCurrent();
        }

        // include without the only attribute
        elseif ($node instanceof Twig_Node_Include && !$node->getAttribute('only')) {
            $this->addLoopToAll();
        }

        // the loop variable is referenced via an attribute
        elseif ($node instanceof Twig_Node_Expression_GetAttr
            && (!$node->getNode('attribute') instanceof Twig_Node_Expression_Constant
                || 'parent' === $node->getNode('attribute')->getAttribute('value')
               )
            && (true === $this->loops[0]->getAttribute('with_loop')
                || ($node->getNode('node') instanceof Twig_Node_Expression_Name
                    && 'loop' === $node->getNode('node')->getAttribute('name')
                   )
               )
        ) {
            $this->addLoopToAll();
        }
    }
開發者ID:nizsheanez,項目名稱:PolymorphCMS,代碼行數:48,代碼來源:Optimizer.php

示例9: leaveNode

 public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     if ($node instanceof HW_TagNode) {
         $node->setAttribute('counter', $this->counter--);
     }
     return $node;
 }
開發者ID:hoangsoft90,項目名稱:hw-hoangweb-plugin,代碼行數:7,代碼來源:template-controller.php


注:本文中的Twig_NodeInterface::setAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。