{@inheritdoc}

@see \Concrete\Core\Application\UserInterface\Sitemap\ProviderInterface::includeMenuInResponse()
420890
public function includeMenuInResponse()
    {
        if (($this->request->query->has('cParentID') && $this->request->query->get('cParentID'))
        || ($this->request->query->has('reloadNode') && $this->request->query->get('reloadNode'))) {
            return false;
        }

        return true;
    }
376072
public function listAction()
    {
        $siterootManager = $this->get('phlexible_siteroot.siteroot_manager');

        $siteroots = [];
        foreach ($siterootManager->findAll() as $siteroot) {
            $siteroots[] = [
                'id' => $siteroot->getId(),
                'title' => $siteroot->getTitle(),
            ];
        }

        return new JsonResponse([
            'siteroots' => $siteroots,
            'count' => count($siteroots),
        ]);
    }
478811
public function list(): ResponseInterface
    {
        return $this->viewResponse('admin/modules', [
            'title'           => I18N::translate('All modules'),
            'modules'         => $this->module_service->all(true),
            'deleted_modules' => $this->module_service->deletedModules(),
        ]);
    }
1266505
protected function addResponseHeaders(RequestInterface $request, Response $response)
    {
        $params = $request->getParams();
        $response->setHeader('Via', sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION));

        $lookup = ($params['cache.lookup'] === true ? 'HIT' : 'MISS') . ' from GuzzleCache';
        if ($header = $response->getHeader('X-Cache-Lookup')) {
            // Don't add duplicates
            $values = $header->toArray();
            $values[] = $lookup;
            $response->setHeader('X-Cache-Lookup', array_unique($values));
        } else {
            $response->setHeader('X-Cache-Lookup', $lookup);
        }

        if ($params['cache.hit'] === true) {
            $xcache = 'HIT from GuzzleCache';
        } elseif ($params['cache.hit'] == 'error') {
            $xcache = 'HIT_ERROR from GuzzleCache';
        } else {
            $xcache = 'MISS from GuzzleCache';
        }

        if ($header = $response->getHeader('X-Cache')) {
            // Don't add duplicates
            $values = $header->toArray();
            $values[] = $xcache;
            $response->setHeader('X-Cache', array_unique($values));
        } else {
            $response->setHeader('X-Cache', $xcache);
        }

        if ($response->isFresh() === false) {
            $response->addHeader('Warning', sprintf('110 GuzzleCache/%s "Response is stale"', Version::VERSION));
            if ($params['cache.hit'] === 'error') {
                $response->addHeader('Warning', sprintf('111 GuzzleCache/%s "Revalidation failed"', Version::VERSION));
            }
        }
    }
641237
public function index(ServerRequestInterface $request): ResponseInterface
    {
        $files        = $request->getQueryParams()['files'] ?? 'local'; // local|unused|external
        $media_folder = $request->getQueryParams()['media_folder'] ?? '';
        $subfolders   = $request->getQueryParams()['subfolders'] ?? 'include'; // include/exclude

        $media_folders = $this->allMediaFolders();

        // Preserve the pagination/filtering/sorting between requests, so that the
        // browser’s back button works. Pagination is dependent on the currently
        // selected folder.
        $table_id = md5($files . $media_folder . $subfolders);

        $title = I18N::translate('Manage media');

        return $this->viewResponse('admin/media', [
            'data_folder'   => WT_DATA_DIR,
            'files'         => $files,
            'media_folder'  => $media_folder,
            'media_folders' => $media_folders,
            'subfolders'    => $subfolders,
            'table_id'      => $table_id,
            'title'         => $title,
        ]);
    }
149661
protected static function defaultUpdateResponse(
        int $updated,
        string $index,
        UriInterface $requestUri,
        CrudInterface $crud,
        EncoderInterface $encoder
    ): ResponseInterface {
        $responses = static::defaultCreateResponses($requestUri, $encoder);
        if ($updated > 0 && ($model = $crud->read($index)) !== null) {
            assert(!($model instanceof PaginatedDataInterface));
            $response = $responses->getContentResponse($model);
        } else {
            $response = $responses->getCodeResponse(404);
        }

        return $response;
    }
1202864
public function updateMenus(ServerRequestInterface $request): ResponseInterface
    {
        $modules = $this->module_service->findByInterface(ModuleMenuInterface::class, true);

        $this->updateStatus($modules, $request);
        $this->updateOrder($modules, 'menu_order', $request);
        $this->updateAccessLevel($modules, ModuleMenuInterface::class, $request);

        return redirect(route('menus'));
    }
275980
private function getMetaRedirectUriFromResponse(
        ResponseInterface $response,
        UriInterface $lastRequestUri
    ): ?UriInterface {
        /* @var WebPage $webPage */
        try {
            $webPage = Webpage::createFromResponse($lastRequestUri, $response);
        } catch (\Exception $exception) {
            return null;
        }

        $redirectUrl = null;
        $selector = 'meta[http-equiv=refresh]';

        /** @noinspection PhpUnhandledExceptionInspection */
        $inspector = new WebPageInspector($webPage);

        /* @var \DOMElement[] $metaRefreshElements */
        $metaRefreshElements = $inspector->querySelectorAll($selector);

        foreach ($metaRefreshElements as $metaRefreshElement) {
            if ($metaRefreshElement->hasAttribute('content')) {
                $contentAttribute = $metaRefreshElement->getAttribute('content');
                $urlMarkerPosition = stripos($contentAttribute, 'url=');

                if ($urlMarkerPosition !== false) {
                    $redirectUrl = substr($contentAttribute, $urlMarkerPosition + strlen('url='));
                }
            }
        }

        if (empty($redirectUrl)) {
            return null;
        }

        return AbsoluteUrlDeriver::derive($lastRequestUri, new Uri($redirectUrl));
    }
614949
public function actionGetRouteRules($siteId = null, $includeGlobal = true): Response
    {
        return $this->asJson(RouteMap::$plugin->routes->getRouteRules($siteId, $includeGlobal));
    }
771509
public function verifyPage(): ResponseInterface
    {
        $this->checkRegistrationAllowed();

        $title = I18N::translate('User verification');

        return $this->viewResponse('register-page', [
            'title' => $title,
        ]);
    }
1118858
private function AddMenuAccessField()
    {
        $name = 'MenuAccess';
        $value = $this->page->Exists() ? $this->page->GetMenuAccess() : (string)MenuAccess::Authorized();
        $select = new Select($name, $value);
        foreach (MenuAccess::AllowedValues() as $access)
        {
            $select->AddOption($access, Trans("Core.PageForm.$name.$access"));
        }
        $this->AddField($select);
        $this->SetRequired($name);
    }
525428
public function loadResponse(string $file, ResponseInterface $response) : ResponseInterface
    {
        return $this->includeResponse('load', $file, $response);
    }
279066
public function pageNotFound(ServerRequestInterface $request) : ResponseInterface
    {
        $acceptType = $request->getHeader('Accept');
        if (is_array($acceptType) && count($acceptType) > 0 && strpos($acceptType[0], 'json') !== false) {
            return new JsonResponse(['error' => ['message' => 'Page not found', 'type' => 'page_not_found']], 404);
        }

        if ($this->contentFor404) {
            $this->contentBlock->addHtmlElement($this->contentFor404);
        } else {
            $this->contentBlock->addFile(__DIR__ . '/../../../../views/404.php', $this);
        }

        return HtmlResponse::create($this->template, 404);
    }
953614
public function registerMenuPage($slug, $title, array $permissions, $link = null, $icon = null, $position = null)
    {
        if ($this->menuPageExists($slug)) {
            return false;
        }

        $slug = trim(Str::slug($slug));
        $title = trim($title);
        if ( ! is_array($permissions)) {
            $permissions = (array)$permissions;
        }
        $link = trim($link);
        $position = (null === $position) ? 1500 : (int)$position;


        if ( ! empty($slug) && ! empty($title)) {
            $this->menuLinks[ $slug ] = [
                'title'       => $title,
                'permissions' => $permissions,
                'link'        => $link,
                'icon'        => $icon,
                'position'    => (int)$position,
            ];

            return $slug;
        }

        return false;
    }
209364
private function insertIntoPostForms(ResponseInterface $response, callable $replace)
    {
        $html = (string) $response->getBody();
        $html = preg_replace_callback('/(<form\s[^>]*method=["\']?POST["\']?[^>]*>)/i', $replace, $html, -1, $count);

        if (!empty($count)) {
            $body = self::createStream();
            $body->write($html);

            return $response->withBody($body);
        }

        return $response;
    }
449647
protected function addChild(ItemInterface $menu, Request $request, $label, $route, $position = null, callable $activeTest = null, $routeParameters = [])
    {
        $menu->addChild($this->createChild($request, $label, $route, $position, $activeTest, $routeParameters))->setExtra('translation_domain', 'tuna_admin');

        return $menu;
    }
167086
private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false, $icon = false, $onclick = false)
    {
        if (!isset($this->menu[$menuName])) {
            $this->menu[$menuName] = array(
                '_hasSubmenu' => false,
                '_order' => $order
            );
        }

        if (empty($subMenuName)) {
            $this->menu[$menuName]['_url']   = $url;
            $this->menu[$menuName]['_order'] = $order;
            $this->menu[$menuName]['_name']  = $menuName;
            $this->menu[$menuName]['_tooltip'] = $tooltip;
            if (!empty($this->menuIcons[$menuName])) {
                $this->menu[$menuName]['_icon'] = $this->menuIcons[$menuName];
            } else {
                $this->menu[$menuName]['_icon'] = '';
            }
        }
        if (!empty($subMenuName)) {
            $this->menu[$menuName][$subMenuName]['_url'] = $url;
            $this->menu[$menuName][$subMenuName]['_order'] = $order;
            $this->menu[$menuName][$subMenuName]['_name'] = $subMenuName;
            $this->menu[$menuName][$subMenuName]['_tooltip'] = $tooltip;
            $this->menu[$menuName][$subMenuName]['_icon'] = $icon;
            $this->menu[$menuName][$subMenuName]['_onclick'] = $onclick;
            $this->menu[$menuName]['_hasSubmenu'] = true;

            if (!array_key_exists('_tooltip', $this->menu[$menuName])) {
                $this->menu[$menuName]['_tooltip'] = $tooltip;
            }
        }
    }