Example #1
0
 /**
  * @param NodeInterface $root
  */
 function __construct(NodeInterface $root)
 {
     // First, evaluate everything that is not an ObjectAccessorNode, ArrayNode
     // or ViewHelperNode so we get all text, numbers, comparators and
     // groupers from the text parts of the expression. All other nodes
     // we leave intact for later processing
     if ($root instanceof RootNode) {
         $this->stack = $root->getChildNodes();
     } else {
         $this->stack = array($root);
     }
 }
Example #2
0
 /**
  * @param NodeInterface $node
  * @return array
  * @see convert()
  */
 public function convertListOfSubNodes(NodeInterface $node)
 {
     switch (count($node->getChildNodes())) {
         case 0:
             return array('initialization' => '', 'execution' => 'NULL');
         case 1:
             return $this->convert(current($node->getChildNodes()));
         default:
             $outputVariableName = $this->variableName('output');
             $initializationPhpCode = sprintf('%s = \'\';', $outputVariableName) . chr(10);
             foreach ($node->getChildNodes() as $childNode) {
                 $converted = $this->convert($childNode);
                 $initializationPhpCode .= $converted['initialization'] . chr(10);
                 $initializationPhpCode .= sprintf('%s .= %s;', $outputVariableName, $converted['execution']) . chr(10);
             }
             return array('initialization' => $initializationPhpCode, 'execution' => $outputVariableName);
     }
 }