/**
  * @param string $path
  * @return string
  * @throws \Exception
  */
 public function render($path = NULL)
 {
     if ($path === NULL) {
         $path = '404';
     }
     /** @var RequestHandler $activeRequestHandler */
     $activeRequestHandler = $this->bootstrap->getActiveRequestHandler();
     $parentHttpRequest = $activeRequestHandler->getHttpRequest();
     $requestPath = $parentHttpRequest->getUri()->getPath();
     $language = explode('/', ltrim($requestPath, '/'))[0];
     if ($language === 'neos') {
         throw new \Exception('NotFoundViewHelper can not be used for neos-routes.', 1435648210);
     }
     $language = $this->localeDetector->detectLocaleFromLocaleTag($language)->getLanguage();
     if ($this->contentDimensionPresetSource->findPresetByUriSegment('language', $language) === NULL) {
         $language = '';
     }
     if ($language !== '') {
         $language .= '/';
     }
     $request = Request::create(new Uri(rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path));
     $matchingRoute = $this->router->route($request);
     if (!$matchingRoute) {
         throw new \Exception(sprintf('Uri with path "%s" could not be found.', rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path), 1426446160);
     }
     $response = new Response();
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get('TYPO3\\Flow\\Http\\Component\\ComponentChain');
     $componentContext = new ComponentContext($request, $response);
     $baseComponentChain->handle($componentContext);
     return $response->getContent();
 }
 /**
  * Parses the given request path and checks if the first path segment is one or a set of content dimension preset
  * identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.
  *
  * If the first path segment contained content dimension information, it is removed from &$requestPath.
  *
  * @param string &$requestPath The request path currently being processed by this route part handler, e.g. "de_global/startseite/ueber-uns"
  * @return array An array of dimension name => dimension values (array of string)
  * @throws InvalidRequestPathException
  * @throws NoSuchDimensionValueException
  */
 protected function parseDimensionsAndNodePathFromRequestPath(&$requestPath)
 {
     $dimensionPresets = $this->contentDimensionPresetSource->getAllPresets();
     if (count($dimensionPresets) === 0) {
         return array();
     }
     $dimensionsAndDimensionValues = array();
     $chosenDimensionPresets = array();
     $matches = array();
     preg_match(self::DIMENSION_REQUEST_PATH_MATCHER, $requestPath, $matches);
     if (!isset($matches['dimensionPresetUriSegments'])) {
         foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
             $dimensionsAndDimensionValues[$dimensionName] = $dimensionPreset['presets'][$dimensionPreset['defaultPreset']]['values'];
             $chosenDimensionPresets[$dimensionName] = $dimensionPreset['defaultPreset'];
         }
     } else {
         $dimensionPresetUriSegments = explode('_', $matches['dimensionPresetUriSegments']);
         if (count($dimensionPresetUriSegments) !== count($dimensionPresets)) {
             throw new InvalidRequestPathException(sprintf('The first path segment of the request URI (%s) does not contain the necessary content dimension preset identifiers for all configured dimensions. This might be an old URI which doesn\'t match the current dimension configuration anymore.', $requestPath), 1413389121);
         }
         foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
             $uriSegment = array_shift($dimensionPresetUriSegments);
             $preset = $this->contentDimensionPresetSource->findPresetByUriSegment($dimensionName, $uriSegment);
             if ($preset === NULL) {
                 throw new NoSuchDimensionValueException(sprintf('Could not find a preset for content dimension "%s" through the given URI segment "%s".', $dimensionName, $uriSegment), 1413389321);
             }
             $dimensionsAndDimensionValues[$dimensionName] = $preset['values'];
             $chosenDimensionPresets[$dimensionName] = $preset['identifier'];
         }
         $requestPath = isset($matches['remainingRequestPath']) ? $matches['remainingRequestPath'] : '';
     }
     if (!$this->contentDimensionPresetSource->isPresetCombinationAllowedByConstraints($chosenDimensionPresets)) {
         throw new InvalidDimensionPresetCombinationException(sprintf('The resolved content dimension preset combination (%s) is invalid or restricted by content dimension constraints. Check your content dimension settings if you think that this is an error.', 'x'), 1428657721);
     }
     return $dimensionsAndDimensionValues;
 }
 private function findPreset($needle)
 {
     return $this->contentDimensionPresetSource->findPresetByUriSegment('language', $needle);
 }