public function indexAction(Request $request)
    {
        $kernelClosure = $this->kernelClosure;
        /** @var \eZ\Publish\Core\MVC\Legacy\Kernel $kernel */
        $kernel = $kernelClosure();

        $legacyMode = $this->configResolver->getParameter('legacy_mode');
        $kernel->setUseExceptions(false);
        // Fix up legacy URI with current request since we can be in a sub-request here.
        $this->uriHelper->updateLegacyURI($request);

        // If we have a layout for legacy AND we're not in legacy mode, we ask the legacy kernel not to generate layout.
        if (isset($this->legacyLayout) && !$legacyMode) {
            $kernel->setUsePagelayout(false);
        }

        $result = $kernel->run();

        $kernel->setUseExceptions(true);

        if ($result instanceof ezpKernelRedirect) {
            return $this->legacyResponseManager->generateRedirectResponse($result);
        }

        $this->legacyHelper->loadDataFromModuleResult($result->getAttribute('module_result'));

        $response = $this->legacyResponseManager->generateResponseFromModuleResult($result);
        $this->legacyResponseManager->mapHeaders(headers_list(), $response);

        return $response;
    }