/**
  * Finds and instantiates a controller that matches the current request.
  * If no controller can be found, an instance of NotFoundControllerInterface is returned.
  *
  * @param RequestInterface $request The request to dispatch
  * @return ControllerInterface
  * @throws NoSuchOptionException
  * @throws Controller\Exception\InvalidControllerException
  */
 protected function resolveController(RequestInterface $request)
 {
     /** @var ActionRequest $request */
     $controllerObjectName = $request->getControllerObjectName();
     if ($controllerObjectName === '') {
         if (isset($this->settings['mvc']['notFoundController'])) {
             throw new NoSuchOptionException('The configuration option Neos.Flow:mvc:notFoundController is deprecated since Flow 2.0. Use the "renderingGroups" option of the production exception handler instead in order to render custom error messages.', 1346949795);
         }
         $exceptionMessage = 'No controller could be resolved which would match your request';
         if ($request instanceof ActionRequest) {
             $exceptionMessage .= sprintf('. Package key: "%s", controller name: "%s"', $request->getControllerPackageKey(), $request->getControllerName());
             if ($request->getControllerSubpackageKey() !== null) {
                 $exceptionMessage .= sprintf(', SubPackage key: "%s"', $request->getControllerSubpackageKey());
             }
             $exceptionMessage .= sprintf('. (%s %s)', $request->getHttpRequest()->getMethod(), $request->getHttpRequest()->getUri());
         }
         throw new Controller\Exception\InvalidControllerException($exceptionMessage, 1303209195, null, $request);
     }
     $controller = $this->objectManager->get($controllerObjectName);
     if (!$controller instanceof ControllerInterface) {
         throw new Controller\Exception\InvalidControllerException('Invalid controller "' . $request->getControllerObjectName() . '". The controller must be a valid request handling controller, ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1202921619, null, $request);
     }
     return $controller;
 }
 /**
  * Create a complete cache identifier for the given
  * request that conforms to cache identifier syntax
  *
  * @param RequestInterface $request
  * @return string
  */
 protected function createCacheIdentifier($request)
 {
     $cacheIdentifiersParts = [];
     do {
         $cacheIdentifiersParts[] = $request->getControllerPackageKey();
         $cacheIdentifiersParts[] = $request->getControllerSubpackageKey();
         $cacheIdentifiersParts[] = $request->getControllerName();
         $cacheIdentifiersParts[] = $request->getControllerActionName();
         $cacheIdentifiersParts[] = $request->getFormat();
         $request = $request->getParentRequest();
     } while ($request instanceof ActionRequest);
     return md5(implode('-', $cacheIdentifiersParts));
 }