Purely internal method, should not be called outside of Neos.Fusion.
public pushContextArray ( array $contextArray ) : void | ||
$contextArray | array | |
Résultat | void |
/** * Evaluate a TypoScript path with a given context without content caching * * This is used to render uncached segments "out of band" in getCachedSegment of ContentCache. * * @param string $path * @param array $contextArray * @return mixed * * TODO Find another way of disabling the cache (especially to allow cached content inside uncached content) */ public function evaluateUncached($path, array $contextArray) { $previousEnableContentCache = $this->enableContentCache; $this->enableContentCache = false; $this->runtime->pushContextArray($contextArray); $result = $this->runtime->evaluate($path); $this->runtime->popContext(); $this->enableContentCache = $previousEnableContentCache; return $result; }
/** * Render the given TypoScript and return the rendered page * * @return string */ protected function renderTypoScript() { $this->typoScriptRuntime->pushContextArray($this->variables); try { $output = $this->typoScriptRuntime->render($this->getTypoScriptPathForCurrentRequest()); } catch (RuntimeException $exception) { throw $exception->getPrevious(); } $this->typoScriptRuntime->popContext(); return $output; }
public function setUp() { parent::setUp(); $this->router->setRoutesConfiguration(null); $this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class); $domainRepository = $this->objectManager->get(DomainRepository::class); $siteRepository = $this->objectManager->get(SiteRepository::class); $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class); $contextProperties = array('workspaceName' => 'live'); $contentContext = $this->contextFactory->create($contextProperties); $siteImportService = $this->objectManager->get(SiteImportService::class); $siteImportService->importFromFile(__DIR__ . '/../../Fixtures/NodeStructure.xml', $contentContext); $this->persistenceManager->persistAll(); /** @var Domain $currentDomain */ $currentDomain = $domainRepository->findOneByActiveRequest(); if ($currentDomain !== null) { $contextProperties['currentSite'] = $currentDomain->getSite(); $contextProperties['currentDomain'] = $currentDomain; } else { $contextProperties['currentSite'] = $siteRepository->findFirst(); } $contentContext = $this->contextFactory->create($contextProperties); $this->contentContext = $contentContext; $this->propertyMapper = $this->objectManager->get(PropertyMapper::class); $this->viewHelper = new NodeViewHelper(); /** @var $requestHandler FunctionalTestRequestHandler */ $requestHandler = self::$bootstrap->getActiveRequestHandler(); $httpRequest = $requestHandler->getHttpRequest(); $httpRequest->setBaseUri(new Uri('http://neos.test/')); $controllerContext = new ControllerContext(new ActionRequest($httpRequest), $requestHandler->getHttpResponse(), new Arguments(array()), new UriBuilder()); $this->inject($this->viewHelper, 'controllerContext', $controllerContext); $typoScriptObject = $this->getAccessibleMock(TemplateImplementation::class, array('dummy'), array(), '', false); $this->tsRuntime = new Runtime(array(), $controllerContext); $this->tsRuntime->pushContextArray(array('documentNode' => $this->contentContext->getCurrentSiteNode()->getNode('home'), 'alternativeDocumentNode' => $this->contentContext->getCurrentSiteNode()->getNode('home/about-us/mission'))); $this->inject($typoScriptObject, 'tsRuntime', $this->tsRuntime); /** @var AbstractTemplateView|\PHPUnit_Framework_MockObject_MockObject $mockView */ $mockView = $this->getAccessibleMock(FluidView::class, array(), array(), '', false); $mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($typoScriptObject)); $viewHelperVariableContainer = new ViewHelperVariableContainer(); $viewHelperVariableContainer->setView($mockView); $this->inject($this->viewHelper, 'viewHelperVariableContainer', $viewHelperVariableContainer); $templateVariableContainer = new TemplateVariableContainer(array()); $this->inject($this->viewHelper, 'templateVariableContainer', $templateVariableContainer); $this->viewHelper->setRenderChildrenClosure(function () use($templateVariableContainer) { $linkedNode = $templateVariableContainer->get('linkedNode'); return $linkedNode !== null ? $linkedNode->getLabel() : ''; }); $this->viewHelper->initialize(); }