StorefrontResponse example

$event = new StorefrontRenderEvent($view$parameters$request$salesChannelContext);

        $this->container->get('event_dispatcher')->dispatch($event);

        $iconCacheEnabled = $this->getSystemConfigService()->get('core.storefrontSettings.iconCache') ?? true;

        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);

        
use Shopware\Storefront\Framework\Routing\StorefrontResponse;

/** * @internal * * @covers \Shopware\Storefront\Framework\Routing\StorefrontResponse */
class StorefrontResponseTest extends TestCase
{
    public function testInit(): void
    {
        $response = new StorefrontResponse();

        static::assertIsArray($response->getData());
        static::assertEmpty($response->getData());

        static::assertNull($response->getContext());
    }

    public function testSetData(): void
    {
        $response = new StorefrontResponse();

        
$subscriber->onError($event);

        static::assertNull($event->getResponse());
    }

    public function testErrorHandled(): void
    {
        $controller = $this->createMock(ErrorController::class);
        $controller
            ->expects(static::once())
            ->method('error')
            ->willReturn(new StorefrontResponse());

        $cacheTracer = $this->createMock(AbstractCacheTracer::class);
        $cacheTracer
            ->expects(static::once())
            ->method('trace')
            ->willReturnCallback(fn (string $name, \Closure $closure) => $closure());

        $requestStack = $this->createMock(RequestStack::class);
        $requestStack->method('getMainRequest')->willReturn(new Request());

        $subscriber = new NotFoundSubscriber(
            
Home | Imprint | This part of the site doesn't use cookies.