/** * On the post parse event, add the "layoutName" variable to the variable container so it can be used by the TemplateView. * * @param \TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $syntaxTreeNode * @param array $viewHelperArguments * @param \TYPO3\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer * @return void */ public static function postParseEvent(\TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, \TYPO3\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer) { if (isset($viewHelperArguments['name'])) { $layoutNameNode = $viewHelperArguments['name']; } else { $layoutNameNode = new \TYPO3\Fluid\Core\Parser\SyntaxTree\TextNode('Default'); } $variableContainer->add('layoutName', $layoutNameNode); }
/** * @test */ public function assignMultipleCanOverridePreviouslyAssignedValues() { $this->templateVariableContainer->expects($this->at(0))->method('exists')->with('foo')->will($this->returnValue(false)); $this->templateVariableContainer->expects($this->at(1))->method('add')->with('foo', 'FooValue'); $this->templateVariableContainer->expects($this->at(2))->method('exists')->with('foo')->will($this->returnValue(true)); $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('foo'); $this->templateVariableContainer->expects($this->at(4))->method('add')->with('foo', 'FooValueOverridden'); $this->templateVariableContainer->expects($this->at(5))->method('exists')->with('bar')->will($this->returnValue(false)); $this->templateVariableContainer->expects($this->at(6))->method('add')->with('bar', 'BarValue'); $this->view->assign('foo', 'FooValue'); $this->view->assignMultiple(array('foo' => 'FooValueOverridden', 'bar' => 'BarValue')); }
/** * Save the associated view helper node in a static public class variable. * called directly after the view helper was built. * * @param ViewHelperNode $syntaxTreeNode * @param array $viewHelperArguments<TextNode> * @param TemplateVariableContainer $variableContainer * @return void */ public static function postParseEvent(ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, TemplateVariableContainer $variableContainer) { /** @var $nameArgument TextNode */ $nameArgument = $viewHelperArguments['name']; $sectionName = $nameArgument->getText(); if (!$variableContainer->exists('sections')) { $variableContainer->add('sections', array()); } $sections = $variableContainer->get('sections'); $sections[$sectionName] = $syntaxTreeNode; $variableContainer->remove('sections'); $variableContainer->add('sections', $sections); }
/** * Save the associated view helper node in a static public class variable. * called directly after the view helper was built. * * @param \TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $syntaxTreeNode * @param array $viewHelperArguments * @param \TYPO3\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer * @return void */ public static function postParseEvent(\TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, \TYPO3\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer) { $sectionName = $viewHelperArguments['name']->getText(); if (!$variableContainer->exists('sections')) { $variableContainer->add('sections', array()); } $sections = $variableContainer->get('sections'); $sections[$sectionName] = $syntaxTreeNode; $variableContainer->remove('sections'); $variableContainer->add('sections', $sections); }
/** * @test * @param string $identifier * @dataProvider reservedVariableNameDataProvider * @expectedException \TYPO3\Fluid\Core\ViewHelper\Exception\InvalidVariableException */ public function attemptToSetReservedVariableInUncoveredLetterCaseThrowsException($identifier) { $this->variableContainer->add(strtoupper($identifier), 'foo'); }