コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Module) {
         $varName = $this->getVarName();
         $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start'))));
         $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
     } elseif ($node instanceof Twig_Node_Block) {
         $varName = $this->getVarName();
         $node->setNode('body', new Twig_Node_Body(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getTemplateName(), $varName), $node->getNode('body'), new Twig_Profiler_Node_LeaveProfile($varName))));
     } elseif ($node instanceof Twig_Node_Macro) {
         $varName = $this->getVarName();
         $node->setNode('body', new Twig_Node_Body(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getTemplateName(), $varName), $node->getNode('body'), new Twig_Profiler_Node_LeaveProfile($varName))));
     }
     return $node;
 }
コード例 #2
0
ファイル: Escaper.php プロジェクト: naldz/cyberden
 /**
  * {@inheritdoc}
  */
 protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Module) {
         if ($env->hasExtension('Twig_Extension_Escaper') && ($defaultStrategy = $env->getExtension('Twig_Extension_Escaper')->getDefaultStrategy($node->getTemplateName()))) {
             $this->defaultStrategy = $defaultStrategy;
         }
         $this->safeVars = array();
         $this->blocks = array();
     } elseif ($node instanceof Twig_Node_AutoEscape) {
         $this->statusStack[] = $node->getAttribute('value');
     } elseif ($node instanceof Twig_Node_Block) {
         $this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
     } elseif ($node instanceof Twig_Node_Import) {
         $this->safeVars[] = $node->getNode('var')->getAttribute('name');
     }
     return $node;
 }