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();
            }
        }
    }