bundles/BlockManagerAdminBundle/EventListener/LayoutView/RelatedLayoutsCountListener.php
public function onBuildView(CollectViewParametersEvent $event): void
    {
        $view = $event->getView();
        if (!$view instanceof LayoutViewInterface) {
            return;
        }

        if ($view->getContext() !== ViewInterface::CONTEXT_ADMIN) {
            return;
        }

        $layout = $view->getLayout();

        $relatedLayoutsCount = 0;
        if ($layout->isShared() && $layout->isPublished()) {
            $relatedLayoutsCount = $this->layoutService->getRelatedLayoutsCount($layout);
        }

        $event->addParameter('related_layouts_count', $relatedLayoutsCount);
    }
public function onBuildView(CollectViewParametersEvent $event): void
    {
        $view = $event->getView();
        if (!$view instanceof LayoutViewInterface) {
            return;
        }

        if ($view->getContext() !== ViewInterface::CONTEXT_ADMIN) {
            return;
        }

        $layout = $view->getLayout();

        $relatedLayoutsCount = 0;
        if ($layout->isShared() && $layout->isPublished()) {
            $relatedLayoutsCount = $this->layoutService->getRelatedLayoutsCount($layout);
        }

        $event->addParameter('related_layouts_count', $relatedLayoutsCount);
    }
public function onBuildView ( CollectViewParametersEvent $ event ) : void { $ view = $ event -> getView ( ) ; if ( ! $ view instanceof LayoutViewInterface ) { return ; } if ( $ view -> getContext ( ) !== ViewInterface :: CONTEXT_ADMIN ) { return ; } $ layout = $ view -> getLayout ( ) ; $ relatedLayoutsCount = 0 ; if ( $ layout -> isShared ( ) && $ layout -> isPublished ( ) ) { $ relatedLayoutsCount = $ this -> layoutService -> getRelatedLayoutsCount ( $ layout ) ; } $ event -> addParameter ( 'related_layouts_count' , $ relatedLayoutsCount ) ; }
Injects the number of layouts connected to the shared layout
provided by the event.
Injects the number of layouts connected to the shared layout provided by the event .