unSupportStorefrontResponse example

if ($iconCacheEnabled) {
            IconCacheTwigFilter::enable();
        }

        $response = Profiler::trace('twig-rendering', fn () => $this->render($view$event->getParameters()new StorefrontResponse()));

        if ($iconCacheEnabled) {
            IconCacheTwigFilter::disable();
        }

        if (!$response instanceof StorefrontResponse) {
            throw StorefrontException::unSupportStorefrontResponse();
        }

        $host = $request->attributes->get(RequestTransformer::STOREFRONT_URL);

        $seoUrlReplacer = $this->container->get(SeoUrlPlaceholderHandlerInterface::class);
        $content = $response->getContent();
        if ($content !== false) {
            $response->setContent(
                $seoUrlReplacer->replace($content$host$salesChannelContext)
            );
        }

        


        $res = StorefrontException::cannotRenderView('test.html.twig', 'Error message', $parameters);

        static::assertEquals(500, $res->getStatusCode());
        static::assertEquals('STOREFRONT__CAN_NOT_RENDER_VIEW', $res->getErrorCode());
        static::assertEquals('Can not render test.html.twig view: Error message with these parameters: {"param":"Param"}', $res->getMessage());
    }

    public function testUnSupportStorefrontResponse(): void
    {
        $res = StorefrontException::unSupportStorefrontResponse();

        static::assertEquals(500, $res->getStatusCode());
        static::assertEquals('STOREFRONT__UN_SUPPORT_STOREFRONT_RESPONSE', $res->getErrorCode());
        static::assertEquals('Symfony render implementation changed. Providing a response is no longer supported', $res->getMessage());
    }

    public function testDontHaveTwigInjected(): void
    {
        $res = StorefrontException::dontHaveTwigInjected('Example\Class');

        static::assertEquals(500, $res->getStatusCode());
        
Home | Imprint | This part of the site doesn't use cookies.