Exemplo n.º 1
0
 /**
  * Log a message if a post is deleted
  *
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint
  * @Flow\Around("method(TYPO3\Neos\View\TypoScriptView->render())")
  * @return void
  */
 public function replacePlaceholdersIfNecessary(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
 {
     $result = $joinPoint->getAdviceChain()->proceed($joinPoint);
     /* @var $typoScriptView TypoScriptView */
     $typoScriptView = $joinPoint->getProxy();
     $viewVariables = ObjectAccess::getProperty($typoScriptView, 'variables', TRUE);
     if (!isset($viewVariables['value']) || !$viewVariables['value']->getNodeType()->isOfType('Sandstorm.Newsletter:Newsletter')) {
         // No newsletter, so logic does not apply
         return $result;
     }
     /* @var $httpRequest Request */
     $httpRequest = $this->controllerContext->getRequest()->getHttpRequest();
     $arguments = $httpRequest->getUri()->getArguments();
     if (!isset($arguments['hmac'])) {
         if ($this->securityContext->isInitialized() && $this->securityContext->hasRole('TYPO3.Neos:Editor')) {
             // Logged into backend, so we don't need to do anything.
             return $result;
         } else {
             // No HMAC sent -- so we return the email INCLUDING placeholders (as per customer's request)
             return $result;
             //return '<h1>Error: HMAC not included in the link.</h1>';
         }
     }
     $actualHmac = $arguments['hmac'];
     $uriWithoutHmac = str_replace('&hmac=' . $actualHmac, '', (string) $httpRequest->getUri());
     $expectedHmac = hash_hmac('sha1', urldecode($uriWithoutHmac), $this->hmacUrlSecret);
     if ($expectedHmac !== $actualHmac) {
         return '<h1>Error: Wrong link clicked.</h1>Please contact your administrator for help';
     }
     $result = preg_replace_callback(ReplacePlaceholdersInLiveImplementation::PLACEHOLDER_REGEX, function ($element) use($arguments) {
         return ObjectAccess::getPropertyPath($arguments, $element[1]);
     }, $result);
     return $result;
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->viewHelperVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $this->viewHelperVariableContainer->expects($this->any())->method('exists')->will($this->returnCallback(array($this, 'viewHelperVariableContainerExistsCallback')));
     $this->viewHelperVariableContainer->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'viewHelperVariableContainerGetCallback')));
     $this->templateVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer');
     $this->uriBuilder = $this->getMock('TYPO3\\Flow\\Mvc\\Routing\\UriBuilder');
     $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
     // BACKPORTER TOKEN #1
     $httpRequest = \TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri('http://localhost/foo'));
     $this->request = $this->getMock('TYPO3\\Flow\\Mvc\\ActionRequest', array(), array($httpRequest));
     $this->request->expects($this->any())->method('isMainRequest')->will($this->returnValue(TRUE));
     $this->controllerContext = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
     $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
     $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->tagBuilder = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TagBuilder');
     $this->arguments = array();
     $this->renderingContext = new \TYPO3\Fluid\Core\Rendering\RenderingContext();
     $this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
     $this->renderingContext->injectViewHelperVariableContainer($this->viewHelperVariableContainer);
     $this->renderingContext->setControllerContext($this->controllerContext);
 }
 /**
  * Sets up this test case
  * @return void
  */
 public function setUp()
 {
     $this->view = $this->getMock(\TYPO3\Flow\Mvc\View\JsonView::class, array('loadConfigurationFromYamlFile'));
     $this->controllerContext = $this->getMock(\TYPO3\Flow\Mvc\Controller\ControllerContext::class, array(), array(), '', false);
     $this->response = $this->getMock(\TYPO3\Flow\Http\Response::class, array());
     $this->controllerContext->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->view->setControllerContext($this->controllerContext);
 }
 public function setUp()
 {
     $this->standaloneView = $this->getAccessibleMock(\TYPO3\Fluid\View\StandaloneView::class, array('dummy'));
     $this->mockRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockControllerContext = $this->getMockBuilder(\TYPO3\Flow\Mvc\Controller\ControllerContext::class)->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockRequest));
     $this->inject($this->standaloneView, 'controllerContext', $this->mockControllerContext);
 }
 /**
  * Sets up this test case
  * @return void
  */
 public function setUp()
 {
     $this->view = $this->getMock('TYPO3\\Flow\\Mvc\\View\\JsonView', array('loadConfigurationFromYamlFile'));
     $this->controllerContext = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
     $this->response = $this->getMock('TYPO3\\Flow\\Http\\Response', array());
     $this->controllerContext->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->view->setControllerContext($this->controllerContext);
 }
 /**
  * Sets up this test case
  * @return void
  */
 public function setUp()
 {
     $this->view = $this->getMockBuilder(\TYPO3\Flow\Mvc\View\JsonView::class)->setMethods(array('loadConfigurationFromYamlFile'))->getMock();
     $this->controllerContext = $this->getMockBuilder(\TYPO3\Flow\Mvc\Controller\ControllerContext::class)->disableOriginalConstructor()->getMock();
     $this->response = $this->createMock(\TYPO3\Flow\Http\Response::class);
     $this->controllerContext->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->view->setControllerContext($this->controllerContext);
 }
 /**
  * @param ControllerContext $controllerContext
  * @return string|ActionRequest|NULL
  */
 public function onLogout(ControllerContext $controllerContext)
 {
     if (is_array($this->redirectAfterLogout) && array_key_exists('action', $this->redirectAfterLogout) && array_key_exists('controller', $this->redirectAfterLogout) && array_key_exists('package', $this->redirectAfterLogout)) {
         $controllerArguments = [];
         if (array_key_exists('controllerArguments', $this->redirectAfterLogout) && is_array($this->redirectAfterLogout['controllerArguments'])) {
             $controllerArguments = $this->redirectAfterLogout['controllerArguments'];
         }
         return $controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(true)->uriFor($this->redirectAfterLogout['action'], $controllerArguments, $this->redirectAfterLogout['controller'], $this->redirectAfterLogout['package']);
     }
 }
 /**
  * Prepare a TypoScriptView for testing that Mocks a request with the given controller and action names.
  *
  * @param string $controllerObjectName
  * @param string $controllerActionName
  * @return TypoScriptView
  */
 protected function buildView($controllerObjectName, $controllerActionName)
 {
     $request = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\ActionRequest')->disableOriginalConstructor()->getMock();
     $request->expects($this->any())->method('getControllerObjectName')->will($this->returnValue($controllerObjectName));
     $request->expects($this->any())->method('getControllerActionName')->will($this->returnValue($controllerActionName));
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($request));
     $view = new TypoScriptView();
     $view->setControllerContext($this->mockControllerContext);
     $this->inject($view, 'fallbackView', $this->mockFallbackView);
     $view->setTypoScriptPathPattern(__DIR__ . '/Fixtures/TypoScript');
     return $view;
 }
Exemplo n.º 9
0
 /**
  * @test
  * @param string $requestUri
  * @param string $sectionArgument
  * @param string $expectedResult
  * @dataProvider getFormActionUriDataProvider
  */
 public function getFormActionUriTests($requestUri, $sectionArgument, $expectedResult)
 {
     $mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockActionRequest));
     $mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($mockHttpRequest));
     $mockUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock();
     $mockUri->expects($this->any())->method('__toString')->will($this->returnValue($requestUri));
     $mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($mockUri));
     $this->formViewHelper->expects($this->any())->method('hasArgument')->with('section')->will($this->returnValue($sectionArgument !== null));
     $this->formViewHelper->_set('arguments', ['section' => $sectionArgument]);
     $this->assertSame($expectedResult, $this->formViewHelper->_call('getFormActionUri'));
 }
 public function setUp()
 {
     $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock();
     $this->mockControllerContext = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext')->disableOriginalConstructor()->getMock();
     $this->mockActionRequest = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\ActionRequest')->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest));
     $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->resourceUriImplementation = new ResourceUriImplementation($this->mockTsRuntime, 'resourceUri/test', 'TYPO3.TypoScript:ResourceUri');
     $this->mockResourceManager = $this->getMockBuilder('TYPO3\\Flow\\Resource\\ResourceManager')->disableOriginalConstructor()->getMock();
     $this->inject($this->resourceUriImplementation, 'resourceManager', $this->mockResourceManager);
     $this->mockI18nService = $this->getMockBuilder('TYPO3\\Flow\\I18n\\Service')->disableOriginalConstructor()->getMock();
     $this->inject($this->resourceUriImplementation, 'i18nService', $this->mockI18nService);
 }
 /**
  * Test if the response headers of the plugin - set within the plugin action / dispatch - were set into the parent response.
  *
  * @dataProvider responseHeadersDataprovider
  * @test
  */
 public function evaluateSetHeaderIntoParent($message, $input, $expected)
 {
     $this->pluginImplementation->expects($this->any())->method('buildPluginRequest')->will($this->returnValue($this->mockActionRequest));
     $parentResponse = new Response();
     $this->_setHeadersIntoResponse($parentResponse, $input['parent']);
     $this->mockControllerContext->expects($this->any())->method('getResponse')->will($this->returnValue($parentResponse));
     $this->mockDispatcher->expects($this->any())->method('dispatch')->will($this->returnCallback(function ($request, $response) use($input) {
         $this->_setHeadersIntoResponse($response, $input['plugin']);
     }));
     $this->pluginImplementation->evaluate();
     foreach ($expected as $expectedKey => $expectedValue) {
         $this->assertEquals($expectedValue, (string) $parentResponse->getHeaders()->get($expectedKey), $message);
     }
 }
 /**
  * Renders the not found view
  *
  * @return string The rendered view
  * @throws \TYPO3\Flow\Mvc\Exception if no request has been set
  * @api
  */
 public function render()
 {
     if (!is_object($this->controllerContext->getRequest())) {
         throw new \TYPO3\Flow\Mvc\Exception('Can\'t render view without request object.', 1192450280);
     }
     $template = file_get_contents($this->getTemplatePathAndFilename());
     $template = str_replace('{BASEURI}', $this->controllerContext->getRequest()->getHttpRequest()->getBaseUri(), $template);
     foreach ($this->variablesMarker as $variableName => $marker) {
         $variableValue = isset($this->variables[$variableName]) ? $this->variables[$variableName] : '';
         $template = str_replace('{' . $marker . '}', $variableValue, $template);
     }
     $this->controllerContext->getResponse()->setStatus(404);
     return $template;
 }
 /**
  * Transforms the value view variable to a serializable
  * array represantion using a YAML view configuration and JSON encodes
  * the result.
  *
  * @return string The JSON encoded variables
  * @api
  */
 public function render()
 {
     $this->controllerContext->getResponse()->setHeader('Content-Type', 'application/json');
     $propertiesToRender = $this->renderArray();
     $options = $this->getOption('jsonEncodingOptions');
     return json_encode($propertiesToRender, $options);
 }
 protected function setUp()
 {
     $this->service = new CacheControlService();
     $this->mockContentCacheAspect = $this->getMock('MOC\\Varnish\\Aspects\\ContentCacheAspect');
     $this->inject($this->service, 'contentCacheAspect', $this->mockContentCacheAspect);
     $this->mockLogger = $this->getMockBuilder('MOC\\Varnish\\Log\\LoggerInterface')->getMock();
     $this->inject($this->service, 'logger', $this->mockLogger);
     $this->contentCacheFrontend = new MetadataAwareStringFrontend('test', new TransientMemoryBackend(new ApplicationContext('Testing')));
     $this->contentCacheFrontend->initializeObject();
     $this->inject($this->service, 'contentCacheFrontend', $this->contentCacheFrontend);
     $this->mockTokenStorage = $this->getMock('MOC\\Varnish\\Service\\TokenStorage');
     $this->inject($this->service, 'tokenStorage', $this->mockTokenStorage);
     $this->mockRequest = $this->getMock('TYPO3\\Flow\\Mvc\\RequestInterface');
     $this->mockResponse = $this->getMock('TYPO3\\Flow\\Http\\Response');
     $this->mockController = $this->getMock('TYPO3\\Neos\\Controller\\Frontend\\NodeController');
     $this->mockControllerContext = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext')->disableOriginalConstructor()->getMock();
     $this->mockController->expects($this->any())->method('getControllerContext')->willReturn($this->mockControllerContext);
     $this->mockArguments = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\Arguments')->getMock();
     $this->mockControllerContext->expects($this->any())->method('getArguments')->willReturn($this->mockArguments);
     $this->mockArguments->expects($this->any())->method('hasArgument')->with('node')->willReturn(TRUE);
     $this->mockArgument = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\Argument')->disableOriginalConstructor()->getMock();
     $this->mockArguments->expects($this->any())->method('getArgument')->with('node')->willReturn($this->mockArgument);
     $this->mockNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface');
     $this->mockArgument->expects($this->any())->method('getValue')->willReturn($this->mockNode);
     $this->mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->willReturn($this->mockContext);
 }
 public function onLogout(ControllerContext $controllerContext)
 {
     // Check if config for redirect is done
     if (is_array($this->redirectAfterLogout) && array_key_exists('action', $this->redirectAfterLogout) && array_key_exists('controller', $this->redirectAfterLogout) && array_key_exists('package', $this->redirectAfterLogout)) {
         $controllerArguments = [];
         if (array_key_exists('controllerArguments', $this->redirectAfterLogout) && is_array($this->redirectAfterLogout['controllerArguments'])) {
             $controllerArguments = $this->redirectAfterLogout['controllerArguments'];
         }
         return $controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(true)->uriFor($this->redirectAfterLogout['action'], $controllerArguments, $this->redirectAfterLogout['controller'], $this->redirectAfterLogout['package']);
     }
     // Neos only logic (configuration at node or via TS)
     /** @var ActionRequest $actionRequest */
     $actionRequest = $controllerContext->getRequest();
     if ($actionRequest->getInternalArgument('__redirectAfterLogout')) {
         return $this->getNodeLinkingService()->createNodeUri($controllerContext, $actionRequest->getInternalArgument('__redirectAfterLogout'));
     }
 }
 /**
  * Build parser configuration
  *
  * @return \TYPO3\Fluid\Core\Parser\Configuration
  */
 protected function buildParserConfiguration()
 {
     $parserConfiguration = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\Configuration');
     if (in_array($this->controllerContext->getRequest()->getFormat(), array('html', NULL))) {
         $parserConfiguration->addInterceptor($this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\Interceptor\\Escape'));
         $parserConfiguration->addInterceptor($this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\Interceptor\\Resource'));
     }
     return $parserConfiguration;
 }
Exemplo n.º 17
0
 /**
  * Get variables from configuration that should be set in the context by default.
  * For example Eel helpers are made available by this.
  *
  * @return array Array with default context variable objects.
  */
 protected function getDefaultContextVariables()
 {
     if ($this->defaultContextVariables === null) {
         $this->defaultContextVariables = array();
         if (isset($this->settings['defaultContext']) && is_array($this->settings['defaultContext'])) {
             $this->defaultContextVariables = EelUtility::getDefaultContextVariables($this->settings['defaultContext']);
         }
         $this->defaultContextVariables['request'] = $this->controllerContext->getRequest();
     }
     return $this->defaultContextVariables;
 }
 public function setUp()
 {
     $this->convertUrisImplementation = $this->getAccessibleMock('TYPO3\\Neos\\TypoScript\\ConvertUrisImplementation', array('tsValue'), array(), '', false);
     $this->mockWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock();
     $this->mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock();
     $this->mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($this->mockWorkspace));
     $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext));
     $this->mockHttpUri = $this->getMockBuilder('TYPO3\\Flow\\Http\\Uri')->disableOriginalConstructor()->getMock();
     $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost'));
     $this->mockHttpRequest = $this->getMockBuilder('TYPO3\\Flow\\Http\\Request')->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri));
     $this->mockActionRequest = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\ActionRequest')->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockControllerContext = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext')->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest));
     $this->mockLinkingService = $this->createMock('TYPO3\\Neos\\Service\\LinkingService');
     $this->convertUrisImplementation->_set('linkingService', $this->mockLinkingService);
     $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->convertUrisImplementation->_set('tsRuntime', $this->mockTsRuntime);
 }
 public function setUp()
 {
     $this->convertUrisImplementation = $this->getAccessibleMock(ConvertUrisImplementation::class, array('tsValue'), array(), '', false);
     $this->mockWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock();
     $this->mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
     $this->mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($this->mockWorkspace));
     $this->mockNode = $this->getMockBuilder(NodeInterface::class)->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext));
     $this->mockHttpUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost'));
     $this->mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri));
     $this->mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock();
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest));
     $this->mockLinkingService = $this->createMock(LinkingService::class);
     $this->convertUrisImplementation->_set('linkingService', $this->mockLinkingService);
     $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->convertUrisImplementation->_set('tsRuntime', $this->mockTsRuntime);
 }
 /**
  * Build parser configuration
  *
  * @return Configuration
  */
 protected function buildParserConfiguration()
 {
     /** @var Configuration $parserConfiguration */
     $parserConfiguration = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\Configuration');
     /** @var EscapeInterceptor $escapeInterceptor */
     $escapeInterceptor = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\Interceptor\\Escape');
     $parserConfiguration->addEscapingInterceptor($escapeInterceptor);
     $request = $this->controllerContext->getRequest();
     if ($request instanceof ActionRequest && in_array($request->getFormat(), array('html', NULL))) {
         /** @var ResourceInterceptor $resourceInterceptor */
         $resourceInterceptor = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\Interceptor\\Resource');
         $parserConfiguration->addInterceptor($resourceInterceptor);
     }
     return $parserConfiguration;
 }
 /**
  * @param ControllerContext $controllerContext
  * @param Site $site
  * @return string
  * @throws NeosException
  */
 public function createSiteUri(ControllerContext $controllerContext, Site $site)
 {
     $primaryDomain = $site->getPrimaryDomain();
     if ($primaryDomain === null) {
         throw new NeosException(sprintf('Cannot link to a site "%s" since it has no active domains.', $site->getName()), 1460443524);
     }
     $requestUri = $controllerContext->getRequest()->getHttpRequest()->getUri();
     $baseUri = $controllerContext->getRequest()->getHttpRequest()->getBaseUri();
     $port = $primaryDomain->getPort() ?: $requestUri->getPort();
     return sprintf('%s://%s%s%s', $primaryDomain->getScheme() ?: $requestUri->getScheme(), $primaryDomain->getHostPattern(), $port && !in_array($port, [80, 443], true) ? ':' . $port : '', rtrim($baseUri->getPath(), '/'));
 }
 /**
  * @param \TYPO3\Flow\Mvc\Controller\ControllerContext $controllerContext
  * @param string $module
  * @param array $moduleConfiguration
  * @param string $modulePath
  * @return array
  */
 protected function collectModuleData(ControllerContext $controllerContext, $module, $moduleConfiguration, $modulePath)
 {
     $moduleUri = $controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(TRUE)->uriFor('index', array('module' => $modulePath), 'Backend\\Module', 'TYPO3.Neos');
     return array('module' => $module, 'modulePath' => $modulePath, 'uri' => $moduleUri, 'label' => isset($moduleConfiguration['label']) ? $moduleConfiguration['label'] : '', 'description' => isset($moduleConfiguration['description']) ? $moduleConfiguration['description'] : '', 'icon' => isset($moduleConfiguration['icon']) ? $moduleConfiguration['icon'] : '', 'hideInMenu' => isset($moduleConfiguration['hideInMenu']) ? (bool) $moduleConfiguration['hideInMenu'] : FALSE);
 }
 /**
  * Renders the URI to a given node instance or -path.
  *
  * @param ControllerContext $controllerContext
  * @param mixed $node A node object or a string node path, if a relative path is provided the baseNode argument is required
  * @param NodeInterface $baseNode
  * @param string $format Format to use for the URL, for example "html" or "json"
  * @param boolean $absolute If set, an absolute URI is rendered
  * @param array $arguments Additional arguments to be passed to the UriBuilder (for example pagination parameters)
  * @param string $section
  * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
  * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
  * @param boolean $resolveShortcuts INTERNAL Parameter - if FALSE, shortcuts are not redirected to their target. Only needed on rare backend occasions when we want to link to the shortcut itself.
  * @return string The rendered URI
  * @throws \InvalidArgumentException if the given node/baseNode is not valid
  * @throws NeosException if no URI could be resolved for the given node
  */
 public function createNodeUri(ControllerContext $controllerContext, $node = null, NodeInterface $baseNode = null, $format = null, $absolute = false, array $arguments = array(), $section = '', $addQueryString = false, array $argumentsToBeExcludedFromQueryString = array(), $resolveShortcuts = true)
 {
     $this->lastLinkedNode = null;
     if (!($node instanceof NodeInterface || is_string($node) || $baseNode instanceof NodeInterface)) {
         throw new \InvalidArgumentException('Expected an instance of NodeInterface or a string for the node argument, or alternatively a baseNode argument.', 1373101025);
     }
     if (is_string($node)) {
         $nodeString = $node;
         if ($nodeString === '') {
             throw new NeosException(sprintf('Empty strings can not be resolved to nodes.', $nodeString), 1415709942);
         }
         preg_match(NodeInterface::MATCH_PATTERN_CONTEXTPATH, $nodeString, $matches);
         if (isset($matches['WorkspaceName']) && $matches['WorkspaceName'] !== '') {
             $node = $this->propertyMapper->convert($nodeString, 'TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface');
         } else {
             if ($baseNode === null) {
                 throw new NeosException('The baseNode argument is required for linking to nodes with a relative path.', 1407879905);
             }
             /** @var ContentContext $contentContext */
             $contentContext = $baseNode->getContext();
             $normalizedPath = $this->nodeService->normalizePath($nodeString, $baseNode->getPath(), $contentContext->getCurrentSiteNode()->getPath());
             $node = $contentContext->getNode($normalizedPath);
         }
         if (!$node instanceof NodeInterface) {
             throw new NeosException(sprintf('The string "%s" could not be resolved to an existing node.', $nodeString), 1415709674);
         }
     } elseif (!$node instanceof NodeInterface) {
         $node = $baseNode;
     }
     if (!$node instanceof NodeInterface) {
         throw new NeosException(sprintf('Node must be an instance of NodeInterface or string, given "%s".', gettype($node)), 1414772029);
     }
     $this->lastLinkedNode = $node;
     if ($resolveShortcuts === true) {
         $resolvedNode = $this->nodeShortcutResolver->resolveShortcutTarget($node);
     } else {
         // this case is only relevant in extremely rare occasions in the Neos Backend, when we want to generate
         // a link towards the *shortcut itself*, and not to its target.
         $resolvedNode = $node;
     }
     if (is_string($resolvedNode)) {
         return $resolvedNode;
     }
     if (!$resolvedNode instanceof NodeInterface) {
         throw new NeosException(sprintf('Could not resolve shortcut target for node "%s"', $node->getPath()), 1414771137);
     }
     /** @var ActionRequest $request */
     $request = $controllerContext->getRequest()->getMainRequest();
     $uriBuilder = clone $controllerContext->getUriBuilder();
     $uriBuilder->setRequest($request);
     $uri = $uriBuilder->reset()->setSection($section)->setCreateAbsoluteUri($absolute)->setArguments($arguments)->setAddQueryString($addQueryString)->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)->setFormat($format ?: $request->getFormat())->uriFor('show', array('node' => $resolvedNode), 'Frontend\\Node', 'TYPO3.Neos');
     return $uri;
 }