bundles/BlockManagerBundle/Templating/Twig/GlobalVariable.php
private function buildLayoutView(string $context = ViewInterface::CONTEXT_DEFAULT)
    {
        $currentRequest = $this->requestStack->getCurrentRequest();
        $masterRequest = $this->requestStack->getMasterRequest();

        if (!$currentRequest instanceof Request || !$masterRequest instanceof Request) {
            return null;
        }

        if ($masterRequest->attributes->has('ngbmExceptionLayoutView')) {
            // After an exception layout is resolved, this case either means that
            // the main layout does not exist at all (because the error
            // happened before the rendering) or that it is already resolved
            // (if the error happened in subrequest), so this is a subsequent
            // call where we can safely return null in all cases.
            return null;
        }

        if (
            !$currentRequest->attributes->has('exception') &&
            $masterRequest->attributes->has('ngbmLayoutView')
        ) {
            // This is the case where we request the main layout more than once
            // within the regular page display, without the exception, so again
            // we return null.
            return null;
        }

        // Once we're here, we either request the main layout when there's no
        // exception, or the exception layout (both of those for the first time).

        $layoutView = false;

        $resolvedRule = $this->layoutResolver->resolveRule();
        if ($resolvedRule instanceof Rule) {
            $layoutView = $this->viewBuilder->buildView(
                $resolvedRule->getLayout(),
                $context,
                [
                    'rule' => $resolvedRule,
                ]
            );
        }

        $masterRequest->attributes->set(
            $currentRequest->attributes->has('exception') ?
                'ngbmExceptionLayoutView' :
                'ngbmLayoutView',
            $layoutView
        );

        return $layoutView;
    }
private function buildLayoutView(string $context = ViewInterface::CONTEXT_DEFAULT)
    {
        $currentRequest = $this->requestStack->getCurrentRequest();
        $masterRequest = $this->requestStack->getMasterRequest();

        if (!$currentRequest instanceof Request || !$masterRequest instanceof Request) {
            return null;
        }

        if ($masterRequest->attributes->has('ngbmExceptionLayoutView')) {
            // After an exception layout is resolved, this case either means that
            // the main layout does not exist at all (because the error
            // happened before the rendering) or that it is already resolved
            // (if the error happened in subrequest), so this is a subsequent
            // call where we can safely return null in all cases.
            return null;
        }

        if (
            !$currentRequest->attributes->has('exception') &&
            $masterRequest->attributes->has('ngbmLayoutView')
        ) {
            // This is the case where we request the main layout more than once
            // within the regular page display, without the exception, so again
            // we return null.
            return null;
        }

        // Once we're here, we either request the main layout when there's no
        // exception, or the exception layout (both of those for the first time).

        $layoutView = false;

        $resolvedRule = $this->layoutResolver->resolveRule();
        if ($resolvedRule instanceof Rule) {
            $layoutView = $this->viewBuilder->buildView(
                $resolvedRule->getLayout(),
                $context,
                [
                    'rule' => $resolvedRule,
                ]
            );
        }

        $masterRequest->attributes->set(
            $currentRequest->attributes->has('exception') ?
                'ngbmExceptionLayoutView' :
                'ngbmLayoutView',
            $layoutView
        );

        return $layoutView;
    }
private function buildLayoutView ( string $ context = ViewInterface :: CONTEXT_DEFAULT ) { $ currentRequest = $ this -> requestStack -> getCurrentRequest ( ) ; $ masterRequest = $ this -> requestStack -> getMasterRequest ( ) ; if ( ! $ currentRequest instanceof Request || ! $ masterRequest instanceof Request ) { return null ; } if ( $ masterRequest -> attributes -> has ( 'ngbmExceptionLayoutView' ) ) { // After an exception layout is resolved, this case either means that // the main layout does not exist at all (because the error // happened before the rendering) or that it is already resolved // (if the error happened in subrequest), so this is a subsequent // call where we can safely return null in all cases. return null ; } if ( ! $ currentRequest -> attributes -> has ( 'exception' ) && $ masterRequest -> attributes -> has ( 'ngbmLayoutView' ) ) { // This is the case where we request the main layout more than once // within the regular page display, without the exception, so again // we return null. return null ; } // Once we're here, we either request the main layout when there's no // exception, or the exception layout (both of those for the first time). $ layoutView = false ; $ resolvedRule = $ this -> layoutResolver -> resolveRule ( ) ; if ( $ resolvedRule instanceof Rule ) { $ layoutView = $ this -> viewBuilder -> buildView ( $ resolvedRule -> getLayout ( ) , $ context , [ 'rule' => $ resolvedRule , ] ) ; } $ masterRequest -> attributes -> set ( $ currentRequest -> attributes -> has ( 'exception' ) ? 'ngbmExceptionLayoutView' : 'ngbmLayoutView' , $ layoutView ) ; return $ layoutView ; }
Resolves the used layout, based on current conditions.

Only resolves and returns the layout view once per request for regular page,
and once if an exception happens. Subsequent calls will simply return null.

See class docs for more details.

@return \Netgen\BlockManager\View\ViewInterface|false|null
Resolves the used layout based on current conditions .