getSecure example

$template->assign('sBasefile', Shopware()->Config()->get('BaseFile'));
        $template->assign('theme', $config);

        $templatePath = 'newsletter/index/' . $mailing['template'];

        if (!empty($mailing['plaintext'])) {
            $templatePath = 'newsletter/alt/' . $mailing['template'];
        }

        if (!$template->isCached($templatePath)) {
            $template->assign('sMailing', $mailing);
            $template->assign('sStart', ($shop->getSecure() ? 'https://' : 'http://') . $shop->getHost() . $shop->getBaseUrl());
            $template->assign('sUserGroup', Shopware()->System()->sUSERGROUP);
            $template->assign('sUserGroupData', Shopware()->System()->sUSERGROUPDATA);
            $template->assign('sMainCategories', Shopware()->Modules()->Categories()->sGetMainCategories());
        }

        return $template;
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Returns mailing data using the mailing id. * * @param int $id * * @return array */

        $shop = $this->contextService->getShopContext()->getShop();
        $name = $this->getCsrfName();

        $response = $this->container->get('front')->Response();
        $response->headers->setCookie(new Cookie(
            $name,
            Random::getAlphanumericString(30),
            0,
            sprintf('%s/', $shop->getPath() ?: ''),
            '',
            $shop->getSecure(),
            false
        ));
    }

    /** * Check if the submitted CSRF token matches with the token stored in the cookie or header */
    private function checkRequest(Request $request): bool
    {
        $name = $this->getCsrfName();

        
/** * @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);
    }

    
if (empty($file) && $request !== null) {
        $file = $request->getBasePath() . '/';
    }

    if ($request !== null && !empty($params['fullPath']) && strpos($file, '/') === 0) {
        $file = $request->getScheme() . '://' . $request->getHttpHost() . $file;
    }

    if ($request === null && Shopware()->Container()->initialized('shop')) {
        $shop = Shopware()->Container()->get('shop');
        $scheme = $shop->getSecure() ? 'https' : 'http';

        $host = $scheme . '://' . $shop->getHost();

        if ($shop->getBasePath()) {
            $host .= $shop->getBasePath();
        }

        $file = $host . '/' . ltrim($file, '/');
    }

    return $file;
}

        }

        $config = Shopware()->Config();
        $inheritance = Shopware()->Container()->get('theme_inheritance');
        $eventManager = Shopware()->Container()->get('events');

        if ($this->getShop() !== null) {
            $defaultContext = [
                'sConfig' => $config,
                'sShop' => $config->get('shopName'),
                'sShopURL' => ($this->getShop()->getSecure() ? 'https://' : 'http://') . $this->getShop()->getHost() . $this->getShop()->getBaseUrl(),
            ];

            // Add theme to the context if given shop (or its main shop) has a template.             $theme = null;
            if ($this->getShop()->getTemplate()) {
                $theme = $inheritance->buildConfig($this->getShop()->getTemplate()$this->getShop(), false);
            } elseif ($this->getShop()->getMain() && $this->getShop()->getMain()->getTemplate()) {
                $theme = $inheritance->buildConfig($this->getShop()->getMain()->getTemplate()$this->getShop(), false);
            }

            if ($theme) {
                
$this->setParams($request->getQuery());
    }

    /** * @return Context */
    public static function createFromShop(ShopwareShop $shop, ShopwareConfig $config)
    {
        $self = new self(
            $shop->getHost() ?? 'localhost',
            $shop->getBaseUrl() ?? '',
            $shop->getSecure(),
            []
        );
        $self->setShopId($shop->getId());
        $self->setUrlToLower($config->get('routerToLower'));
        $self->setBaseFile($config->get('baseFile'));
        $self->setRemoveCategory((bool) $config->get('routerRemoveCategory'));

        return $self;
    }
}
 $request->getHttpHost()
                   . $request->getBaseUrl() . '/';
        }

        $shop = $this->get(ModelManager::class)->getRepository(Shop::class)->findOneBy(['default' => true]);
        if (!$shop->getHost()) {
            return null;
        }

        return sprintf(
            '%s://%s%s/',
            $shop->getSecure() ? 'https' : 'http',
            $shop->getHost(),
            $shop->getBasePath()
        );
    }

    /** * Do http caching jobs * * @return void */
    public function onPreDispatch(Enlight_Controller_ActionEventArgs $args)
    {
// 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 */
$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);

        
'http_errors' => FALSE,
      'cookies' => $guzzle_cookie_jar,
      'allow_redirects' => FALSE,
    ]);

    // When logging in via the HTTP mock, the child site will issue a session     // cookie without the secure attribute set. While this cookie will be stored     // in the Guzzle CookieJar, it will not be used on subsequent requests.     // Update the BrowserKit CookieJar so that subsequent requests have the     // correct cookie.     $cookie = $guzzle_cookie_jar->getCookieByName($this->insecureSessionName);
    $this->assertFalse($cookie->getSecure(), 'The insecure cookie does not have the secure attribute');
    /** @var \Symfony\Component\BrowserKit\CookieJar $browser_kit_cookie_jar */
    $browser_kit_cookie_jar = $this->getSession()->getDriver()->getClient()->getCookieJar();
    $browser_kit_cookie_jar->updateFromSetCookie($response->getHeader('Set-Cookie')$this->baseUrl);

    // Follow the location header.     $path = $this->getPathFromLocationHeader($response, FALSE);
    $parsed_path = parse_url($path);
    $query = [];
    if (isset($parsed_path['query'])) {
      parse_str($parsed_path['query']$query);
    }
    
/** @var Shop $shop */
            $shop = $this->container->get('shop');
        } else {
            /** @var Shop $shop */
            $shop = $this->container->get(\Shopware\Components\Model\ModelManager::class)->getRepository(Shop::class)->getActiveDefault();
        }

        if ($shop->getMain()) {
            $shop = $shop->getMain();
        }

        if ($shop->getSecure()) {
            return 'https://' . $shop->getHost() . $shop->getBasePath() . '/' . $this->createPublicPath();
        }

        return 'http://' . $shop->getHost() . $shop->getBasePath() . '/' . $this->createPublicPath();
    }

    /** * @return string */
    private function createPublicPath()
    {
        

        $values = [];
        $uri = $request->getUri();
        $scheme = $uri->getScheme();
        $host = $uri->getHost();
        $path = $uri->getPath() ?: '/';

        foreach ($this->cookies as $cookie) {
            if ($cookie->matchesPath($path)
                && $cookie->matchesDomain($host)
                && !$cookie->isExpired()
                && (!$cookie->getSecure() || $scheme === 'https')
            ) {
                $values[] = $cookie->getName().'='
                    .$cookie->getValue();
            }
        }

        return $values
            ? $request->withHeader('Cookie', \implode('; ', $values))
            : $request;
    }

    

        $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()
            );
        }

        
'mail' => $mail,
        ];
    }

    /** * @return array */
    private function getDefaultMailContext(Shop $shop)
    {
        return [
            'sShop' => $this->container->get(Shopware_Components_Config::class)->get('ShopName'),
            'sShopURL' => ($shop->getSecure() ? 'https://' : 'http://') . $shop->getHost() . $shop->getBaseUrl(),
            'sConfig' => $this->container->get(Shopware_Components_Config::class),
        ];
    }

    /** * Replace the name of the email template with a more human readable name. The names from the document types * are used for this. */
    private function getFriendlyNameOfDocumentEmail(string $mailName): string
    {
        if ($mailName === 'sORDERDOCUMENTS') {
            
return false;
        }

        if (!$this->config->get('sendRegisterConfirmation')) {
            return false;
        }

        /** @var \Shopware\Bundle\StoreFrontBundle\Struct\Shop $shop */
        $shop = $this->contextService->getShopContext()->getShop();
        $shopUrl = 'http://' . $shop->getHost() . $shop->getUrl();

        if ($shop->getSecure()) {
            $shopUrl = 'https://' . $shop->getHost() . $shop->getUrl();
        }

        $context = [
            'sMAIL' => $email,
            'sShop' => $this->config->get('ShopName'),
            'sShopURL' => $shopUrl,
            'sConfig' => $this->config,
        ];

        $namespace = $this->snippetManager->getNamespace('frontend/salutation');
        
Home | Imprint | This part of the site doesn't use cookies.