/** * {@inheritdoc} * * @return string */ public function evaluate() { $actionRequest = $this->tsRuntime->getControllerContext()->getRequest(); if (!$actionRequest instanceof ActionRequest) { $actionRequest = null; } $fluidTemplate = new Helpers\FluidView($this, $actionRequest); $templatePath = $this->getTemplatePath(); if ($templatePath === null) { throw new \Exception(sprintf("\n\t\t\t\tNo template path set.\n\t\t\t\tMost likely you didn't configure `templatePath` in your TypoScript object correctly.\n\t\t\t\tFor example you could add and adapt the following line to your TypoScript:\n\t\t\t\t`prototype(%s) < prototype(Neos.Fusion:Template) {\n\t\t\t\t\ttemplatePath = 'resource://Vendor.Package/Private/Templates/MyObject.html'\n\t\t\t\t}`\n\t\t\t", $templatePath, $this->typoScriptObjectName)); } $fluidTemplate->setTemplatePathAndFilename($templatePath); $partialRootPath = $this->getPartialRootPath(); if ($partialRootPath !== null) { $fluidTemplate->setPartialRootPath($partialRootPath); } $layoutRootPath = $this->getLayoutRootPath(); if ($layoutRootPath !== null) { $fluidTemplate->setLayoutRootPath($layoutRootPath); } // Template resources need to be evaluated from the templates package not the requests package. if (strpos($templatePath, 'resource://') === 0) { $templateResourcePathParts = parse_url($templatePath); $fluidTemplate->setResourcePackage($templateResourcePathParts['host']); } foreach ($this->properties as $key => $value) { if (in_array($key, $this->ignoreProperties)) { continue; } if (!is_array($value)) { // if a value is a SIMPLE TYPE, e.g. neither an Eel expression nor a TypoScript object, // we can just evaluate it (to handle processors) and then assign it to the template. $evaluatedValue = $this->tsValue($key); $fluidTemplate->assign($key, $evaluatedValue); } else { // It is an array; so we need to create a "proxy" for lazy evaluation, as it could be a // nested TypoScript object, Eel expression or simple value. $fluidTemplate->assign($key, new Helpers\FusionPathProxy($this, $this->path . '/' . $key, $value)); } } $this->initializeView($fluidTemplate); $sectionName = $this->getSectionName(); if ($sectionName !== null) { return $fluidTemplate->renderSection($sectionName); } else { return $fluidTemplate->render(); } }
public function setUp() { parent::setUp(); $this->editableViewHelper = $this->getAccessibleMock(EditableViewHelper::class, array('renderChildren')); $this->mockPrivilegeManager = $this->getMockBuilder(PrivilegeManagerInterface::class)->getMock(); $this->inject($this->editableViewHelper, 'privilegeManager', $this->mockPrivilegeManager); $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock(); $this->inject($this->editableViewHelper, 'nodeAuthorizationService', $this->mockNodeAuthorizationService); $this->mockContentElementEditableService = $this->getMockBuilder(ContentElementEditableService::class)->getMock(); $this->inject($this->editableViewHelper, 'contentElementEditableService', $this->mockContentElementEditableService); $this->mockTemplateImplementation = $this->getMockBuilder(TemplateImplementation::class)->disableOriginalConstructor()->getMock(); $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock(); $this->mockContentContext = $this->getMockBuilder(ContentContext::class)->disableOriginalConstructor()->getMock(); $this->mockNode = $this->getMockBuilder(NodeInterface::class)->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext)); $this->mockNode->expects($this->any())->method('getNodeType')->will($this->returnValue(new NodeType('Acme.Test:Headline', [], []))); $this->mockTsContext = array('node' => $this->mockNode); $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext)); $this->mockTemplateImplementation->expects($this->any())->method('getTsRuntime')->will($this->returnValue($this->mockTsRuntime)); $this->mockView = $this->getAccessibleMock(FluidView::class, array(), array(), '', false); $this->mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($this->mockTemplateImplementation)); $this->editableViewHelper->initializeArguments(); }