private function switchContext(Context $context, bool $keepCurrentInStack = false): void
    {
        $command = new BuildContextConfig($this, $context, $this->config);
        $this->messageBus->dispatch($command::NAME, $command);

        if ($command->getConfig()) {
            $this->config = $command->getConfig();
        }

        if ($keepCurrentInStack && $this->context) {
            $this->contextStack[] = $this->context;
        }

        $this->context = $context;

        $event = new ContextEntered($this, $context);
        $this->messageBus->dispatch($event::NAME, $event);
    }