/** * @param string $identifier * @param \TYPO3\CMS\Fluid\Core\Parser\ParsingState $parsingState * @return void */ public function store($identifier, \TYPO3\CMS\Fluid\Core\Parser\ParsingState $parsingState) { $identifier = $this->sanitizeIdentifier($identifier); $this->variableCounter = 0; $generatedRenderFunctions = ''; if ($parsingState->getVariableContainer()->exists('sections')) { $sections = $parsingState->getVariableContainer()->get('sections'); // @todo refactor to $parsedTemplate->getSections() foreach ($sections as $sectionName => $sectionRootNode) { $generatedRenderFunctions .= $this->generateCodeForSection($this->convertListOfSubNodes($sectionRootNode), 'section_' . sha1($sectionName), 'section ' . $sectionName); } } $generatedRenderFunctions .= $this->generateCodeForSection($this->convertListOfSubNodes($parsingState->getRootNode()), 'render', 'Main Render function'); $convertedLayoutNameNode = $parsingState->hasLayout() ? $this->convert($parsingState->getLayoutNameNode()) : array('initialization' => '', 'execution' => 'NULL'); $classDefinition = 'class FluidCache_' . $identifier . ' extends \\TYPO3\\CMS\\Fluid\\Core\\Compiler\\AbstractCompiledTemplate'; $templateCode = <<<EOD %s { public function getVariableContainer() { \t// @todo \treturn new \\TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer(); } public function getLayoutName(\\TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContextInterface \$renderingContext) { \$currentVariableContainer = \$renderingContext->getTemplateVariableContainer(); %s return %s; } public function hasLayout() { return %s; } %s } EOD; $templateCode = sprintf($templateCode, $classDefinition, $convertedLayoutNameNode['initialization'], $convertedLayoutNameNode['execution'], $parsingState->hasLayout() ? 'TRUE' : 'FALSE', $generatedRenderFunctions); $this->templateCache->set($identifier, $templateCode); }
/** * @test */ public function setRootNodeCanBeReadOutAgain() { $rootNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode(); $this->parsingState->setRootNode($rootNode); $this->assertSame($this->parsingState->getRootNode(), $rootNode, 'Root node could not be read out again.'); }