public function onProductShow(ResourceControllerEvent $event): void
    {
        $product = $event->getSubject();
        if (!$product instanceof ProductInterface) {
            return;
        }

        $currentRequest = $this->requestStack->getCurrentRequest();
        if ($currentRequest instanceof Request) {
            $currentRequest->attributes->set('nglayouts_sylius_product', $product);
            // We set context here instead in a ContextProvider, since sylius.product.show
            // event happens too late, after onKernelRequest event has already been executed
            $this->context->set('sylius_product_id', (int) $product->getId());
        }
    }
public function onProductShow(ResourceControllerEvent $event): void
    {
        $product = $event->getSubject();
        if (!$product instanceof ProductInterface) {
            return;
        }

        $currentRequest = $this->requestStack->getCurrentRequest();
        if ($currentRequest instanceof Request) {
            $currentRequest->attributes->set('nglayouts_sylius_product', $product);
            // We set context here instead in a ContextProvider, since sylius.product.show
            // event happens too late, after onKernelRequest event has already been executed
            $this->context->set('sylius_product_id', (int) $product->getId());
        }
    }
public function onProductShow ( ResourceControllerEvent $ event ) : void { $ product = $ event -> getSubject ( ) ; if ( ! $ product instanceof ProductInterface ) { return ; } $ currentRequest = $ this -> requestStack -> getCurrentRequest ( ) ; if ( $ currentRequest instanceof Request ) { $ currentRequest -> attributes -> set ( 'nglayouts_sylius_product' , $ product ) ; // We set context here instead in a ContextProvider, since sylius.product.show // event happens too late, after onKernelRequest event has already been executed $ this -> context -> set ( 'sylius_product_id' , ( int ) $ product -> getId ( ) ) ; } }
Sets the currently displayed product to the request,
to be able to match with layout resolver.
Sets the currently displayed product to the request to be able to match with layout resolver .