/** * @return array */ public function getConvertTestValues() { $treeBooleanRoot = new RootNode(); $treeBooleanRoot->addChildNode(new TextNode('1')); $treeBooleanRoot->addChildNode(new TextNode('!=')); $treeBooleanRoot->addChildNode(new TextNode('2')); $treeBoolean = new BooleanNode($treeBooleanRoot); $simpleRoot = new RootNode(); $simpleRoot->addChildNode(new TextNode('foobar')); $multiRoot = new RootNode(); $multiRoot->addChildNode(new TextNode('foo')); $multiRoot->addChildNode(new TextNode('bar')); $multiRoot->addChildNode(new TextNode('baz')); return array(array(new ObjectAccessorNode('_all'), '$renderingContext->getVariableProvider()->getAll()'), array(new ObjectAccessorNode('foo.bar'), '$renderingContext->getVariableProvider()->getByPath(\'foo.bar\', $array0)'), array(new ObjectAccessorNode('foo.bar', array('array', 'array')), 'isset($renderingContext->getVariableProvider()[\'foo\'][\'bar\']) ? $renderingContext->getVariableProvider()[\'foo\'][\'bar\'] : NULL'), array(new BooleanNode(new TextNode('TRUE')), 'TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::convertToBoolean( $expression1( TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::gatherContext($renderingContext, $array0) ), $renderingContext )'), array(new BooleanNode(new TextNode('1 = 1')), 'TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::convertToBoolean( $expression1( TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::gatherContext($renderingContext, $array0) ), $renderingContext )'), array($treeBoolean, 'TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::convertToBoolean( $expression1( TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::gatherContext($renderingContext, $array0) ), $renderingContext )'), array(new TernaryExpressionNode('1 ? 2 : 3', array(1, 2, 3)), '$ternaryExpression1(TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\Expression\\TernaryExpressionNode::gatherContext($renderingContext, $array0[1]), $renderingContext)'), array(new EscapingNode(new TextNode('foo')), 'htmlspecialchars(\'foo\', ENT_QUOTES)'), array(new ViewHelperNode(new RenderingContextFixture(), 'f', 'render', array('section' => new TextNode('test'), 'partial' => 'test'), new ParsingState()), 'TYPO3Fluid\\Fluid\\ViewHelpers\\RenderViewHelper::renderStatic($arguments0, $renderChildrenClosure1, $renderingContext)'), array($simpleRoot, '\'foobar\''), array($multiRoot, '$output0'), array(new TextNode('test'), '\'test\''), array(new NumericNode('3'), '3'), array(new NumericNode('4.5'), '4.5'), array(new ArrayNode(array('foo', 'bar')), '$array0'), array(new ArrayNode(array(0, new TextNode('test'), new ArrayNode(array('foo', 'bar')))), '$array0')); }
/** * @return array */ public function getConvertTestValues() { $treeBooleanRoot = new RootNode(); $treeBooleanRoot->addChildNode(new TextNode('1')); $treeBooleanRoot->addChildNode(new TextNode('!=')); $treeBooleanRoot->addChildNode(new TextNode('2')); $treeBoolean = new BooleanNode($treeBooleanRoot); $simpleRoot = new RootNode(); $simpleRoot->addChildNode(new TextNode('foobar')); $multiRoot = new RootNode(); $multiRoot->addChildNode(new TextNode('foo')); $multiRoot->addChildNode(new TextNode('bar')); $multiRoot->addChildNode(new TextNode('baz')); return array(array(new ObjectAccessorNode('_all'), '$renderingContext->getVariableProvider()->getAll()'), array(new ObjectAccessorNode('foo.bar'), '$renderingContext->getVariableProvider()->getByPath(\'foo.bar\', $array0)'), array(new ObjectAccessorNode('foo.bar', array('array', 'array')), '$renderingContext->getVariableProvider()[\'foo\'][\'bar\']'), array(new BooleanNode(new TextNode('TRUE')), '\\TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::evaluateStack($renderingContext, $array0)'), array(new BooleanNode(new TextNode('1 = 1')), '\\TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::evaluateStack($renderingContext, $array0)'), array($treeBoolean, '\\TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::evaluateStack($renderingContext, $array0)'), array(new TernaryExpressionNode('1 ? 2 : 3', array(1, 2, 3)), '\\TYPO3Fluid\\Fluid\\Core\\Parser\\SyntaxTree\\Expression\\TernaryExpressionNode::evaluateExpression($renderingContext, $string0, $array1)'), array(new ViewHelperNode(new ViewHelperResolver(), 'f', 'render', array('section' => new TextNode('test'), 'partial' => 'test'), new ParsingState()), 'TYPO3Fluid\\Fluid\\ViewHelpers\\RenderViewHelper::renderStatic($arguments0, $renderChildrenClosure1, $renderingContext)'), array($simpleRoot, '\'foobar\''), array($multiRoot, '$output0'), array(new TextNode('test'), '\'test\''), array(new NumericNode('3'), '3'), array(new NumericNode('4.5'), '4.5'), array(new ArrayNode(array('foo', 'bar')), '$array0'), array(new ArrayNode(array(0, new TextNode('test'), new ArrayNode(array('foo', 'bar')))), '$array0')); }
/** * @test */ public function objectsAreComparedStrictlyInUnequalComparison() { $object1 = new \stdClass(); $object2 = new \stdClass(); $rootNode = new RootNode(); $object1Node = $this->getMock(ObjectAccessorNode::class, array('evaluate'), array('foo')); $object1Node->expects($this->any())->method('evaluate')->will($this->returnValue($object1)); $object2Node = $this->getMock(ObjectAccessorNode::class, array('evaluate'), array('foo')); $object2Node->expects($this->any())->method('evaluate')->will($this->returnValue($object2)); $rootNode->addChildNode($object1Node); $rootNode->addChildNode(new TextNode('!=')); $rootNode->addChildNode($object2Node); $booleanNode = new BooleanNode($rootNode); $this->assertTrue($booleanNode->evaluate($this->renderingContext)); }
/** * Render the parsed template with rendering context * * @param RenderingContextInterface $renderingContext The rendering context to use * @return string Rendered string */ public function render(RenderingContextInterface $renderingContext) { return $this->rootNode->evaluate($renderingContext); }
/** * Stores the syntax tree child nodes in the Widget Context, so they can be * rendered with <f:widget.renderChildren> lateron. * * @param array $childNodes The SyntaxTree Child nodes of this ViewHelper. * @return void */ public function setChildNodes(array $childNodes) { $rootNode = new RootNode(); foreach ($childNodes as $childNode) { $rootNode->addChildNode($childNode); } $this->widgetContext->setViewHelperChildNodes($rootNode, $this->renderingContext); }
/** * @test */ public function setChildNodesAddsChildNodesToWidgetContext() { $this->widgetContext = new \Neos\FluidAdaptor\Core\Widget\WidgetContext(); $this->viewHelper->injectWidgetContext($this->widgetContext); $node1 = $this->createMock(AbstractNode::class); $node2 = $this->getMockBuilder(TextNode::class)->disableOriginalConstructor()->getMock(); $node3 = $this->createMock(AbstractNode::class); $rootNode = new RootNode(); $rootNode->addChildNode($node1); $rootNode->addChildNode($node2); $rootNode->addChildNode($node3); $renderingContext = $this->createMock(RenderingContextInterface::class); $this->viewHelper->_set('renderingContext', $renderingContext); $this->viewHelper->setChildNodes(array($node1, $node2, $node3)); $this->assertEquals($rootNode, $this->widgetContext->getViewHelperChildNodes()); }
/** * Looks for URIs pointing to package resources and in place of those adds * ViewHelperNode instances using the ResourceViewHelper. * * @param NodeInterface $node * @param integer $interceptorPosition One of the INTERCEPT_* constants for the current interception point * @param ParsingState $parsingState the current parsing state. Not needed in this interceptor. * @return NodeInterface the modified node */ public function process(NodeInterface $node, $interceptorPosition, ParsingState $parsingState) { /** @var $node TextNode */ if (strpos($node->getText(), 'Public/') === false) { return $node; } $textParts = preg_split(self::PATTERN_SPLIT_AT_RESOURCE_URIS, $node->getText(), -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $node = new RootNode(); foreach ($textParts as $part) { $matches = []; if (preg_match(self::PATTERN_MATCH_RESOURCE_URI, $part, $matches)) { $arguments = ['path' => new TextNode($matches['Path'])]; if ($this->defaultPackageKey !== null) { $arguments['package'] = new TextNode($this->defaultPackageKey); } if (isset($matches['Package']) && preg_match(Package::PATTERN_MATCH_PACKAGEKEY, $matches['Package'])) { $arguments['package'] = new TextNode($matches['Package']); } $resourceUriNode = new ResourceUriNode($arguments, $parsingState); $node->addChildNode($resourceUriNode); } else { $textNode = new TextNode($part); $node->addChildNode($textNode); } } return $node; }