getGlobalParams example


    public function preFilter($params, ?Context $context = null)
    {
        // Add support for "shopware.php?sViewport,cat&sCategory=3"         if (\is_string($params)) {
            $params = (string) parse_url($params, PHP_URL_QUERY);
            $params = str_replace(',', '=', $params);
            parse_str($params$params);
        }

        $globalParams = $context ? $context->getGlobalParams() : [];

        if (isset($params['sViewport'])) {
            $params['controller'] = $params['sViewport'];
        }
        if (isset($params['sAction'])) {
            $params['action'] = $params['sAction'];
        }
        unset($params['title']$params['sViewport']$params['sAction']);

        if (isset($params['controller']) || isset($params['module'])) {
            if (isset($params['module'])) {
                
        $config->setShop($shop);

        $context = $router->getContext();
        $newContext = Context::createFromShop($shop$config);
        // Reuse the host         if ($newContext->getHost() === null) {
            $newContext->setHost($context->getHost());
            $newContext->setBaseUrl($context->getBaseUrl());
            $newContext->setSecure($context->isSecure());
        }
        // Reuse the global params like controller and action         $globalParams = $context->getGlobalParams();
        $newContext->setGlobalParams($globalParams);
        $router->setContext($newContext);
    }

    public function onPreDispatch(Enlight_Controller_EventArgs $args)
    {
        /** @var Enlight_Controller_Front $front */
        $front = $args->getSubject();
        $request = $front->Request();
        /** @var RouterInterface $router */
        $router = $front->ensureRouter();
        
Home | Imprint | This part of the site doesn't use cookies.