setSecure example

/** @var Shopware_Components_Config $config */
        $config = $container->get(Shopware_Components_Config::class);
        // Register the shop (we're too soon)         $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();
        
/** * @return DetachedShop */
    protected function fixActive(Shop $shop)
    {
        $shop = DetachedShop::createFromShop($shop);

        $main = $shop->getMain();
        if ($main !== null) {
            $main = DetachedShop::createFromShop($main);
            $shop->setHost($main->getHost());
            $shop->setSecure($main->getSecure());
            $shop->setBasePath($shop->getBasePath() ?: $main->getBasePath());
            $shop->setTemplate($main->getTemplate());
            $shop->setCurrencies($main->getCurrencies());
            $shop->setChildren($main->getChildren());
            $shop->setCustomerScope($main->getCustomerScope());
        }

        $shop->setBaseUrl($shop->getBaseUrl() ?: $shop->getBasePath());

        return DetachedShop::createFromShop($shop);
    }

    
return $globalParams;
    }

    /** * @return void */
    public function updateFromEnlightRequest(EnlightRequest $request)
    {
        $this->setHost($request->getHttpHost());
        $this->setBaseUrl($request->getBaseUrl());
        $this->setSecure($request->isSecure());
        $this->setGlobalParams(self::getGlobalParamsFromRequest($request));
        $this->setParams($request->getQuery());
    }

    /** * @return Context */
    public static function createFromShop(ShopwareShop $shop, ShopwareConfig $config)
    {
        $self = new self(
            $shop->getHost() ?? 'localhost',
            

        $struct = new self();
        $struct->setId($shop->getId());
        $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId());

        $struct->setCustomerScope($shop->getMain() ? $shop->getMain()->getCustomerScope() : $shop->getCustomerScope());
        $struct->setIsDefault($shop->getDefault());
        $struct->setName($shop->getName());
        $struct->setHost($shop->getHost());
        $struct->setPath($shop->getBasePath());
        $struct->setUrl($shop->getBaseUrl());
        $struct->setSecure($shop->getSecure());
        if ($shop->getCategory()) {
            $struct->setCategory(
                Category::createFromCategoryEntity($shop->getCategory())
            );
        }

        if ($shop->getFallback()) {
            $struct->setFallbackId(
                $shop->getFallback()->getId()
            );
        }

        
$baseUrls = array_map(static function DContext $context) {
            return $context->getBaseUrl();
        }$routerContexts);

        $robotsTxtGenerator = $this->get(RobotsTxtGeneratorInterface::class);
        $baseUrls = array_unique($baseUrls);

        $robotsTxtGenerator->setRouterContext($routerContexts);
        $robotsTxtGenerator->setBaseUrls($baseUrls);
        $robotsTxtGenerator->setHost($shop->getHost());
        $robotsTxtGenerator->setSecure($shop->getSecure());

        $this->View()->assign('robotsTxt', $robotsTxtGenerator);
        $this->Response()->headers->set('content-type', 'text/plain; charset=utf-8');
    }

    /** * @return array<int, Context> */
    private function getRouterContext(Shop $mainShop): array
    {
        $config = $this->container->get(Shopware_Components_Config::class);

        


        if (isset($data['Max-Age'])) {
            $this->setMaxAge($data['Max-Age']);
        }

        if (isset($data['Expires'])) {
            $this->setExpires($data['Expires']);
        }

        if (isset($data['Secure'])) {
            $this->setSecure($data['Secure']);
        }

        if (isset($data['Discard'])) {
            $this->setDiscard($data['Discard']);
        }

        if (isset($data['HttpOnly'])) {
            $this->setHttpOnly($data['HttpOnly']);
        }

        // Set the remaining values that don't have extra validation logic
$parent = $data;
        if ($data['parent']) {
            $parent = $data['parent'];
        }

        $shop->setTemplate($this->templateHydrator->hydrate($parent));
        $shop->setParentId((int) $parent['__shop_id']);
        $shop->setHost($parent['__shop_host']);
        $shop->setPath($parent['__shop_base_path']);
        $shop->setCustomerScope((bool) $parent['__shop_customer_scope']);
        $shop->setUrl($data['__shop_base_url'] ?: $parent['__shop_base_url']);
        $shop->setSecure((bool) $parent['__shop_secure']);

        $hosts = [];
        if ($parent['__shop_hosts']) {
            $hosts = explode('\n', $parent['__shop_hosts']);
            $hosts = array_unique(array_values(array_filter($hosts)));
        }
        $shop->setHosts($hosts);

        if ($data['__shopAttribute_id']) {
            $this->attributeHydrator->addAttribute($shop$data, 'shopAttribute');
        }

        


        if ($expires) {
            $this->setExpires($expires);
        }

        if ($path) {
            $this->setPath($path);
        }

        if ($secure) {
            $this->setSecure($secure);
        }

        if ($httponly) {
            $this->setHttponly($httponly);
        }
    }

    public function __toString()
    {
        return $this->toString();
    }

    
// Update path info         $request->setPathInfo($this->createPathInfo($request$shop));

        $host = $request->getHeader('X_FORWARDED_HOST');
        if ($host !== null && $host === $shop->getHost()) {
            // If the base path is null, set it to empty string. Otherwise the request will try to assemble the base path. On a reverse proxy setup with varnish this will fail on virtual URLs like /en             // The X-Forwarded-Host header is only set in such environments             if ($shop->getBasePath() === null) {
                $shop->setBasePath('');
            }

            $request->setSecure($shop->getSecure());
            $request->setBasePath($shop->getBasePath());
            $request->setBaseUrl($shop->getBaseUrl());
            $request->setHttpHost($shop->getHost());
        }

        $this->validateShop($shop);
        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);
    }

    /** * @return void */
Home | Imprint | This part of the site doesn't use cookies.