getDefaultControllerName example

$response->setStatusCode($targetErrorCode);

        // Page not Found should not get logged in error handler         $response->unsetExceptions();

        switch ($targetEmotionId) {
            case -2:
            case null:
                $this->forward(
                    $this->get('front')->Dispatcher()->getDefaultAction(),
                    $this->get('front')->Dispatcher()->getDefaultControllerName()
                );
                break;
            case -1:
                $this->forward('genericError', null, null, ['code' => $targetErrorCode]);
                break;
            default:
                // Try to load the emotion landingpage, render default error in case it is unavailable                 try {
                    $result = $this->get('shopware.emotion.emotion_landingpage_loader')->load(
                        $targetEmotionId,
                        $this->get(ContextServiceInterface::class)->getShopContext()
                    );
return $this->fillDefaults($context$query);
    }

    /** * Fills up default values for module, controller and action */
    private function fillDefaults(Context $context, array $query): array
    {
        $defaults = [
            $context->getModuleKey() => $this->dispatcher->getDefaultModule(),
            $context->getControllerKey() => $this->dispatcher->getDefaultControllerName(),
            $context->getActionKey() => $this->dispatcher->getDefaultAction(),
        ];

        return array_merge($defaults$query);
    }
}

    public function generate(array $params, Context $context)
    {
        $route = [];

        if (\array_key_exists('_seo', $params)) {
            unset($params['_seo']);
        }

        $module = $params[$context->getModuleKey()] ?? $this->dispatcher->getDefaultModule();
        $controller = $params[$context->getControllerKey()] ?? $this->dispatcher->getDefaultControllerName();
        $action = $params[$context->getActionKey()] ?? $this->dispatcher->getDefaultAction();

        unset($params[$context->getModuleKey()],
            $params[$context->getControllerKey()],
            $params[$context->getActionKey()]);

        if ($module !== $this->dispatcher->getDefaultModule()) {
            $route[] = $module;
        }

        $paramCount = \count($params);
        
Home | Imprint | This part of the site doesn't use cookies.