bundle/EventListener/SetCurrentConfigListener.php
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $attributes = $request->attributes;
        if ($attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
            return;
        }

        if (!$attributes->has('itemType')) {
            return;
        }

        $config = $this->loadConfig($attributes->get('itemType'));

        $customParams = $request->query->get('customParams', []);
        if (!is_array($customParams)) {
            throw new RuntimeException(
                sprintf(
                    'Invalid custom parameters specification for "%s" item type.',
                    $attributes->get('itemType')
                )
            );
        }

        $config->addParameters($customParams);

        $configLoadEvent = new ConfigLoadEvent($config);

        Kernel::VERSION_ID >= 40300 ?
            $this->eventDispatcher->dispatch($configLoadEvent, ContentBrowserEvents::CONFIG_LOAD) :
            $this->eventDispatcher->dispatch(ContentBrowserEvents::CONFIG_LOAD, $configLoadEvent);

        $this->container->set('netgen_content_browser.current_config', $config);
    }
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $attributes = $request->attributes;
        if ($attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
            return;
        }

        if (!$attributes->has('itemType')) {
            return;
        }

        $config = $this->loadConfig($attributes->get('itemType'));

        $customParams = $request->query->get('customParams', []);
        if (!is_array($customParams)) {
            throw new RuntimeException(
                sprintf(
                    'Invalid custom parameters specification for "%s" item type.',
                    $attributes->get('itemType')
                )
            );
        }

        $config->addParameters($customParams);

        $configLoadEvent = new ConfigLoadEvent($config);

        Kernel::VERSION_ID >= 40300 ?
            $this->eventDispatcher->dispatch($configLoadEvent, ContentBrowserEvents::CONFIG_LOAD) :
            $this->eventDispatcher->dispatch(ContentBrowserEvents::CONFIG_LOAD, $configLoadEvent);

        $this->container->set('netgen_content_browser.current_config', $config);
    }
public function onKernelRequest ( GetResponseEvent $ event ) : void { if ( ! $ event -> isMasterRequest ( ) ) { return ; } $ request = $ event -> getRequest ( ) ; $ attributes = $ request -> attributes ; if ( $ attributes -> get ( SetIsApiRequestListener :: API_FLAG_NAME ) !== true ) { return ; } if ( ! $ attributes -> has ( 'itemType' ) ) { return ; } $ config = $ this -> loadConfig ( $ attributes -> get ( 'itemType' ) ) ; $ customParams = $ request -> query -> get ( 'customParams' , [ ] ) ; if ( ! is_array ( $ customParams ) ) { throw new RuntimeException ( sprintf ( 'Invalid custom parameters specification for "%s" item type.' , $ attributes -> get ( 'itemType' ) ) ) ; } $ config -> addParameters ( $ customParams ) ; $ configLoadEvent = new ConfigLoadEvent ( $ config ) ; Kernel :: VERSION_ID >= 40300 ? $ this -> eventDispatcher -> dispatch ( $ configLoadEvent , ContentBrowserEvents :: CONFIG_LOAD ) : $ this -> eventDispatcher -> dispatch ( ContentBrowserEvents :: CONFIG_LOAD , $ configLoadEvent ) ; $ this -> container -> set ( 'netgen_content_browser.current_config' , $ config ) ; }
Injects the current config into container.
Injects the current config into container .