isMaintenanceRequest example

new HttpCacheHitEvent($item$request$response)
        );

        return $response;
    }

    public function write(Request $request, Response $response): string
    {
        $key = $this->cacheKeyGenerator->generate($request);

        // maintenance mode active and current ip is whitelisted > disable caching         if ($this->maintenanceResolver->isMaintenanceRequest($request)) {
            return $key;
        }

        if ($response instanceof StorefrontResponse) {
            $response->setData([]);
            $response->setContext(null);
        }

        $tags = $this->tracer->get('all');

        $tags = array_filter($tagsstatic function Dstring $tag): bool {
            
/** * shouldRedirect returns true, when the given request should be redirected to the maintenance page. * This would be the case, for example, when the maintenance mode is active and the client's IP address * is not listed in the maintenance mode whitelist. */
    public function shouldRedirect(Request $request): bool
    {
        return $this->isSalesChannelRequest()
            && !$request->attributes->getBoolean(PlatformRequest::ATTRIBUTE_IS_ALLOWED_IN_MAINTENANCE)
            && !$this->isXmlHttpRequest($request)
            && !$this->isErrorControllerRequest($request)
            && $this->isMaintenanceRequest($request);
    }

    /** * shouldRedirectToShop returns true, when the given request to the maintenance page should be redirected to the shop. * This would be the case, for example, when the maintenance mode is not active or if it is active * the client's IP address is listed in the maintenance mode whitelist. */
    public function shouldRedirectToShop(Request $request): bool
    {
        return !$this->isXmlHttpRequest($request)
            && !$this->isErrorControllerRequest($request)
            


    /** * Test if the maintenance mode is active by request. * * @dataProvider maintenanceModeInactiveProvider * @dataProvider maintenanceModeActiveProvider */
    public function testIsMaintenanceRequest(Request $request, bool $expected): void
    {
        static::assertEquals(
            (new MaintenanceModeResolver($this->getRequestStack($request)new CoreMaintenanceModeResolver(new EventDispatcher())))->isMaintenanceRequest($request),
            $expected
        );
    }

    /** * @return array<string, array{0: Request, 1: boolean}> */
    public static function maintenanceModeInactiveProvider(): array
    {
        return [
            'maintenance mode is inactive, no sales channel request' => [
                
Home | Imprint | This part of the site doesn't use cookies.