commit 2b6ab667774f904d1f1813461828c4a48ce47a5d Author: Joel Pittet Date: Sun May 26 11:30:58 2013 -0700 spacing cleanup diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php index 2af494a..6bed88e 100644 --- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php +++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php @@ -31,23 +31,23 @@ class TwigNodeVisitor implements \Twig_NodeVisitorInterface { * Implements Twig_NodeVisitorInterface::enterNode(). */ function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) { -// if ($node instanceof \Twig_Node_Expression_Function) { -// $name = $node->getAttribute('name'); -// $func = $env->getFunction($name); -// -// // Optimization: Do not support nested functions. -// if ($this->isReference && $func instanceof \Twig_Function_Function) { -// $this->isReference = FALSE; -// } -// if ($func instanceof TwigReferenceFunction) { -// // We need to create a TwigReference -// $this->isReference = TRUE; -// } -// } -// if ($node instanceof \Twig_Node_Print) { -// // Our injected render_var needs arguments passed by reference -- in case of render array -// $this->isReference = TRUE; -// } + // if ($node instanceof \Twig_Node_Expression_Function) { + // $name = $node->getAttribute('name'); + // $func = $env->getFunction($name); + + // // Optimization: Do not support nested functions. + // if ($this->isReference && $func instanceof \Twig_Function_Function) { + // $this->isReference = FALSE; + // } + // if ($func instanceof TwigReferenceFunction) { + // // We need to create a TwigReference + // $this->isReference = TRUE; + // } + // } + // if ($node instanceof \Twig_Node_Print) { + // // Our injected render_var needs arguments passed by reference -- in case of render array + // $this->isReference = TRUE; + // } return $node; } @@ -62,7 +62,7 @@ function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) { */ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) { if ($node instanceof \Twig_Node_Print) { -// $this->isReference = FALSE; + // $this->isReference = FALSE; $class = get_class($node); return new $class( @@ -71,16 +71,16 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) { ); } -// if ($this->isReference) { -// if ($node instanceof \Twig_Node_Expression_Name) { -// $name = $node->getAttribute('name'); -// return new TwigNodeExpressionNameReference($name, $node->getLine()); -// } -// elseif ($node instanceof \Twig_Function_Function) { -// // Do something! -// $this->isReference = FALSE; -// } -// } + // if ($this->isReference) { + // if ($node instanceof \Twig_Node_Expression_Name) { + // $name = $node->getAttribute('name'); + // return new TwigNodeExpressionNameReference($name, $node->getLine()); + // } + // elseif ($node instanceof \Twig_Function_Function) { + // // Do something! + // $this->isReference = FALSE; + // } + // } return $node; } diff --git a/core/lib/Drupal/Core/Template/TwigReferenceNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigReferenceNodeVisitor.php index 50f7874..b74f671 100644 --- a/core/lib/Drupal/Core/Template/TwigReferenceNodeVisitor.php +++ b/core/lib/Drupal/Core/Template/TwigReferenceNodeVisitor.php @@ -1,5 +1,10 @@ isAttributePath) > 0 ? array_sum($this->isAttributePath) === 0 : TRUE; -// if ($this->isReference && $validPath && !($node instanceof \Twig_Node_Expression_GetAttr || $node instanceof \Twig_Node_Expression_Name || $node instanceof \Twig_Node_Expression_Constant || $node instanceof \Twig_Node_Expression_Array)) { -// $this->isReference = FALSE; -// } + // if ($this->isReference && $validPath && !($node instanceof \Twig_Node_Expression_GetAttr || $node instanceof \Twig_Node_Expression_Name || $node instanceof \Twig_Node_Expression_Constant || $node instanceof \Twig_Node_Expression_Array)) { + // $this->isReference = FALSE; + // } - if ($node instanceof \Twig_Node_Expression_Function) { + if ($node instanceof \Twig_Node_Expression_Function) { $name = $node->getAttribute('name'); $func = $env->getFunction($name); @@ -43,21 +48,23 @@ function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) { array_unshift($this->dataAttributes, array()); } } -// if ($node instanceof \Twig_Node_Print) { -// // Our injected render_var needs arguments passed by reference -- in case of render array -// $this->isReference = TRUE; -// $node->setAttribute('twig_reference', TRUE); -// array_unshift($this->dataAttributes, array()); -// } + + // if ($node instanceof \Twig_Node_Print) { + // // Our injected render_var needs arguments passed by reference -- in case of render array + // $this->isReference = TRUE; + // $node->setAttribute('twig_reference', TRUE); + // array_unshift($this->dataAttributes, array()); + // } + if ($node instanceof \Twig_Node_Expression_GetAttr) { - $nodeI = $node->getNode('node'); - $nodeI->setAttribute('expression_path', 'node'); - $attribute = $node->getNode('attribute'); - $attribute->setAttribute('expression_path', 'attribute'); -// $node->setAttribute('count', $this->attrCounter); -// if ($validPath) { -// $this->attrCounter++; -// } + $nodeI = $node->getNode('node'); + $nodeI->setAttribute('expression_path', 'node'); + $attribute = $node->getNode('attribute'); + $attribute->setAttribute('expression_path', 'attribute'); + // $node->setAttribute('count', $this->attrCounter); + // if ($validPath) { + // $this->attrCounter++; + // } } return $node; @@ -82,15 +89,16 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) { $this->isReference = FALSE; } -// if ($node instanceof \Twig_Node_Print) { -// $this->isReference = FALSE; -// -// $class = get_class($node); -// return new $class( -// new \Twig_Node_Expression_Function('render', new \Twig_Node(array($node->getNode('expr'))), $node->getLine()), -// $node->getLine() -// ); -// } + // if ($node instanceof \Twig_Node_Print) { + // $this->isReference = FALSE; + + // $class = get_class($node); + // return new $class( + // new \Twig_Node_Expression_Function('render', new \Twig_Node(array($node->getNode('expr'))), $node->getLine()), + // $node->getLine() + // ); + // } + $validPath = count($this->isAttributePath) > 0 ? array_sum($this->isAttributePath) === 0 : TRUE; if ($this->isReference && $validPath) { @@ -107,25 +115,25 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) { $type = $node->getAttribute('type'); $newNode = new TwigNodeExpressionGetAttrReference($nodeI, $attribute, $arguments, $type, $node->getLine()); -// $newNode->setAttribute('count', $node->getAttribute('count')); -// $this->attrCounter--; + // $newNode->setAttribute('count', $node->getAttribute('count')); + // $this->attrCounter--; array_push($this->dataAttributes[0], $newNode); return $node; } } -// if ($node instanceof \Twig_Function_Function) { -// // Do something! -// $this->isReference = FALSE; -// } + // if ($node instanceof \Twig_Function_Function) { + // // Do something! + // $this->isReference = FALSE; + // } if ($node->hasAttribute('expression_path')) { array_shift($this->isAttributePath); } -// if ($node instanceof \Twig_Node_Expression_GetAttr && $validPath) { -// $this->attrCounter--; -// } + // if ($node instanceof \Twig_Node_Expression_GetAttr && $validPath) { + // $this->attrCounter--; + // } return $node; }