public function setContext(Site $site, Request $request, $disablePostDispatch = false)
    {
        $doDispatch = false;

        if (!$this->context || $this->context->getId() !== $site->getId()) {
            $doDispatch = true;
        }

        $this->context = $site;

        // Dispatch the context init event
        if ($doDispatch) {

            // On context change, we need to remove the older contextes else we
            // would experience strict fails on dependent context set
            $this->dependentContext = [];

            $this->dispatcher->dispatch(SiteEvents::EVENT_INIT, new SiteInitEvent($this->context, $request));

            if ($disablePostDispatch) {
                // We are in hook_boot(), set post-init to run later during
                // hook_init() ensuring that Drupal is fully bootstrapped,
                // it fixes lots of bugs such has the layout manager may use
                // the Drupal menu to find the current node context
                $this->postInitRun = false;
            } else {
                $this->dispatchPostInit();
            }
        }
    }
public function setContext(Site $site, Request $request, $disablePostDispatch = false)
    {
        $doDispatch = false;

        if (!$this->context || $this->context->getId() !== $site->getId()) {
            $doDispatch = true;
        }

        $this->context = $site;

        // Dispatch the context init event
        if ($doDispatch) {

            // On context change, we need to remove the older contextes else we
            // would experience strict fails on dependent context set
            $this->dependentContext = [];

            $this->dispatcher->dispatch(SiteEvents::EVENT_INIT, new SiteInitEvent($this->context, $request));

            if ($disablePostDispatch) {
                // We are in hook_boot(), set post-init to run later during
                // hook_init() ensuring that Drupal is fully bootstrapped,
                // it fixes lots of bugs such has the layout manager may use
                // the Drupal menu to find the current node context
                $this->postInitRun = false;
            } else {
                $this->dispatchPostInit();
            }
        }
    }
public function setContext ( Site $ site , Request $ request , $ disablePostDispatch = false ) { $ doDispatch = false ; if ( ! $ this -> context || $ this -> context -> getId ( ) !== $ site -> getId ( ) ) { $ doDispatch = true ; } $ this -> context = $ site ; // Dispatch the context init event if ( $ doDispatch ) { // On context change, we need to remove the older contextes else we // would experience strict fails on dependent context set $ this -> dependentContext = [ ] ; $ this -> dispatcher -> dispatch ( SiteEvents :: EVENT_INIT , new SiteInitEvent ( $ this -> context , $ request ) ) ; if ( $ disablePostDispatch ) { // We are in hook_boot(), set post-init to run later during // hook_init() ensuring that Drupal is fully bootstrapped, // it fixes lots of bugs such has the layout manager may use // the Drupal menu to find the current node context $ this -> postInitRun = false ; } else { $ this -> dispatchPostInit ( ) ; } } }
Set current site context

@param Site $site
Site we are initing
@param Request $request
Incomming request that setup the site
@param bool $disablePostDispatch
If set, no event will be raised, please note this should never ever
be used, except during ucms_site_boot() which will pre-set the site
without knowing if the context is valid or not
Set current site context