/** * @param string $identifier * @param ParsingState $parsingState * @return void */ public function store($identifier, ParsingState $parsingState) { if ($this->isDisabled()) { if ($this->renderingContext->isCacheEnabled()) { // Compiler is disabled but cache is enabled. Flush cache to make sure. $this->renderingContext->getCache()->flush($identifier); } $parsingState->setCompilable(FALSE); return; } $identifier = $this->sanitizeIdentifier($identifier); $this->nodeConverter->setVariableCounter(0); $generatedRenderFunctions = $this->generateSectionCodeFromParsingState($parsingState); $generatedRenderFunctions .= $this->generateCodeForSection($this->nodeConverter->convertListOfSubNodes($parsingState->getRootNode()), 'render', 'Main Render function'); $classDefinition = 'class ' . $identifier . ' extends \\TYPO3Fluid\\Fluid\\Core\\Compiler\\AbstractCompiledTemplate'; $templateCode = <<<EOD <?php %s { public function getLayoutName(\\TYPO3Fluid\\Fluid\\Core\\Rendering\\RenderingContextInterface \$renderingContext) { \$layout = %s; if (!\$layout) { \$layout = '%s'; } return \$layout; } public function hasLayout() { return %s; } public function addCompiledNamespaces(\\TYPO3Fluid\\Fluid\\Core\\Rendering\\RenderingContextInterface \$renderingContext) { \$renderingContext->getViewHelperResolver()->addNamespaces(%s); } %s } EOD; $templateCode = sprintf($templateCode, $classDefinition, '$renderingContext->getVariableProvider()->get(\'layoutName\')', $parsingState->getVariableContainer()->get('layoutName'), $parsingState->hasLayout() ? 'TRUE' : 'FALSE', var_export($this->renderingContext->getViewHelperResolver()->getNamespaces(), TRUE), $generatedRenderFunctions); $this->renderingContext->getCache()->set($identifier, $templateCode); }