getDefaultAction example

$targetErrorCode = $this->get('config')->get('PageNotFoundCode', 404);

        $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,
                        
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);
    }
}
/** * Returns the action method of the given request class. * If no action name is set in the request class, the default action is used. * * @return string */
    public function getActionMethod(Enlight_Controller_Request_Request $request)
    {
        $action = $request->getActionName();
        if (empty($action)) {
            $action = $this->getDefaultAction();
            $request->setActionName($action);
        }
        $formatted = $this->formatActionName($action);

        return strtolower($formatted[0]) . substr($formatted, 1) . 'Action';
    }

    /** * Returns the full path of the controller name by the given request class. * To generate the full controller path the module and controller name must be set in the given request object. * The module and controller path is imploded by '_' * * @return string */

    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);
        if ($paramCount > 0 || $controller !== $this->dispatcher->getDefaultControllerName() || $action !== $this->dispatcher->getDefaultAction()) {
            
Home | Imprint | This part of the site doesn't use cookies.