getBasePath example

protected function getUnprefixedName(Request $request) {
    if ($test_prefix = $this->drupalValidTestUa()) {
      $session_name = $test_prefix;
    }
    elseif (isset($this->options['cookie_domain'])) {
      // If the user specifies the cookie domain, also use it for session name.       $session_name = $this->options['cookie_domain'];
    }
    else {
      // Otherwise use $base_url as session name, without the protocol       // to use the same session identifiers across HTTP and HTTPS.       $session_name = $request->getHost() . $request->getBasePath();
      // Replace "core" out of session_name so core scripts redirect properly,       // specifically install.php.       $session_name = preg_replace('#/core$#', '', $session_name);
    }

    return substr(hash('sha256', $session_name), 0, 32);
  }

  /** * Return the session cookie domain. * * The Set-Cookie response header and its domain attribute are defined in RFC * 2109, RFC 2965 and RFC 6265 each one superseding the previous version. * * @see http://tools.ietf.org/html/rfc2109 * @see http://tools.ietf.org/html/rfc2965 * @see http://tools.ietf.org/html/rfc6265 * * @param \Symfony\Component\HttpFoundation\Request $request * The request. * * @returns string|null * The session cookie domain, or NULL if the calculated value is invalid. */
// Make sure we have the right separator for the web context         if (DIRECTORY_SEPARATOR !== '/') {
            $file = str_replace(DIRECTORY_SEPARATOR, '/', $file);
        }

        if (strpos($file, './') === 0) {
            $file = substr($file, 2);
        }

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

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

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

    
    // routed through Drupal, whereas private files should be served by Drupal,     // so they need to be. The difference is most apparent when $script_path     // is not empty (i.e., when not using clean URLs).     $clean_url_settings = [
      'clean' => '',
      'unclean' => 'index.php/',
    ];
    $public_directory_path = \Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath();
    foreach ($clean_url_settings as $clean_url_setting => $script_path) {
      $clean_urls = $clean_url_setting == 'clean';
      $request = $this->prepareRequestForGenerator($clean_urls);
      $base_path = $request->getSchemeAndHttpHost() . $request->getBasePath();
      $this->checkUrl('public', '', $basename$base_path . '/' . $public_directory_path . '/' . $basename_encoded);
      $this->checkUrl('private', '', $basename$base_path . '/' . $script_path . 'system/files/' . $basename_encoded);
    }
    $this->assertEquals('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', $this->fileUrlGenerator->generateString('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', FALSE));
  }

  /** * Download a file from the URL generated by generateString(). * * Create a file with the specified scheme, directory and filename; check that * the URL generated by FileUrlGeneratorInterface::generateString() for the * specified file equals the specified URL; fetch the URL and then compare the * contents to the file. * * @param string $scheme * A scheme, e.g. "public". * @param string $directory * A directory, possibly "". * @param string $filename * A filename. * @param string $expected_url * The expected URL. */
/** * @param Shop $shop * * @return Shopware_Components_Config */
    public function setShop($shop)
    {
        $this->_shop = $shop;
        $this->load();
        $this->offsetSet('host', $shop->getHost());
        $this->offsetSet('basePath', $shop->getHost() . $shop->getBasePath());
        if ($shop->getTitle() !== null) {
            $this->offsetSet('shopName', $shop->getTitle());
        }

        return $this;
    }

    /** * Format name method * * @param string $name * * @return string */
 [$system->sUSERGROUP]);
            }
            if (empty($system->sUSERGROUPDATA['tax']) && !empty($system->sUSERGROUPDATA['id'])) {
                $config['sARTICLESOUTPUTNETTO'] = 1; // Old template                 Shopware()->Session()->set('sOutputNet', true);
            } else {
                Shopware()->Session()->set('sOutputNet', false);
            }
        }

        if ($request !== null) {
            $sPathBase = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
        } else {
            $sPathBase = 'http://' . $config->get('basePath');
        }
        $system->sPathArticleImg = $sPathBase . '/media/image/';
        $system->sPathBanner = $sPathBase . $config->get('banner') . '/';
        $system->sPathStart = $sPathBase . $config->get('baseFile');

        return $system;
    }

    /** * Event listener method * * @return \Shopware_Components_Modules */
private function getStoreFrontBaseUrl(): string
    {
        $config = $this->container->get(Shopware_Components_Config::class);

        $request = null;
        if ($this->container->initialized('front')) {
            $request = $this->container->get('front')->Request();
        }

        if ($request !== null) {
            return $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
        }

        return 'http://' . $config->get('basePath');
    }

    private function getStoreFrontShopId(): int
    {
        return $this->getShop()->getId();
    }

    private function getStoreFrontCurrencyId(): int
    {

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

    

  public function onException(ExceptionEvent $event) {
    $exception = $event->getThrowable();
    if ($this->shouldRedirectToInstaller($exception$this->connection)) {
      // Only redirect if this is an HTML response (i.e., a user trying to view       // the site in a web browser before installing it).       $request = $event->getRequest();
      $format = $request->query->get(MainContentViewSubscriber::WRAPPER_FORMAT, $request->getRequestFormat());
      if ($format == 'html') {
        $event->setResponse(new RedirectResponse($request->getBasePath() . '/core/install.php', 302, ['Cache-Control' => 'no-cache']));
      }
    }
  }

  /** * Registers the methods in this class that should be listeners. * * @return array * An array of event listener definitions. */
  public static function getSubscribedEvents(): array {
    

        $technicallyRequiredCookies = $this->getTechnicallyRequiredCookies();

        $this->removeCookies($request$responsestatic function Dstring $cookieKey) use ($technicallyRequiredCookies) {
            return $technicallyRequiredCookies->hasCookieWithName($cookieKey) || $cookieKey === self::XDEBUG_COOKIE_NAME;
        });
    }

    protected function removeCookies(Request $request, Response $response, callable $validationFunction): void
    {
        $requestCookies = $request->cookies->all();
        $cookieBasePath = $request->getBasePath();

        $cookiePath = $cookieBasePath . '/';
        $currentPath = $cookieBasePath . $request->getPathInfo();
        $currentPathWithoutSlash = '/' . trim($currentPath, '/');
        foreach ($response->headers->getCookies() as $responseCookie) {
            $cookieName = $responseCookie->getName();

            if (!$validationFunction($cookieName)) {
                if (\array_key_exists($cookieName$requestCookies)) {
                    continue;
                }

                
Context $context
    ): array {
        $media = [];
        $themeData = [];
        $themeFolderId = $this->getMediaDefaultFolderId($context);

        $installedConfiguration = null;
        if ($theme && \is_array($theme->getThemeJson()) && $this->pluginConfigurationFactory) {
            $installedConfiguration = $this->pluginConfigurationFactory->createFromThemeJson(
                $theme->getTechnicalName() ?? 'childTheme',
                $theme->getThemeJson(),
                $pluginConfiguration->getBasePath(),
                false
            );
        }

        if (
            $pluginConfiguration->getPreviewMedia()
            && $pluginConfiguration->getPreviewMedia() !== $installedConfiguration?->getPreviewMedia()
            && (
                $theme === null
                || $theme->getPreviewMedia() === null
                || basename($installedConfiguration?->getPreviewMedia() ?? '') !== $theme->getPreviewMedia()->getFileNameIncludingExtension()
            )
$this->requestStack = $requestStack;
        $this->basePath = $basePath;
        $this->secure = $secure;
    }

    public function getBasePath(): string
    {
        if (!$request = $this->requestStack->getMainRequest()) {
            return $this->basePath;
        }

        return $request->getBasePath();
    }

    public function isSecure(): bool
    {
        if (!$request = $this->requestStack->getMainRequest()) {
            return $this->secure;
        }

        return $request->isSecure();
    }
}
return;
        }

        $optinService->delete(OptinServiceInterface::TYPE_CUSTOMER_LOGIN_FROM_BACKEND, $hash);

        $shop = $this->getShopRepository()->getActiveById($data['shopId']);
        if ($shop === null) {
            throw new RuntimeException('Shop not found');
        }

        $path = $shop->getBasePath();
        if ($path === null || $path === '') {
            $path = '/';
        }

        // Update right domain cookies         $this->Response()->headers->setCookie(new Cookie('shop', $data['shopId'], 0, $path));
        $this->Response()->headers->setCookie(new Cookie('sUniqueID', Random::getString(20), 0, $path));
        $this->Response()->headers->setCookie(new Cookie('session-' . $data['shopId']$data['sessionId'], 0, $path));

        $this->redirect($shop->getBaseUrl());
    }

    

  protected function handleException(\Exception $e$request$type) {
    if ($this->shouldRedirectToInstaller($e$this->container ? $this->container->get('database') : NULL)) {
      return new RedirectResponse($request->getBasePath() . '/core/install.php', 302, ['Cache-Control' => 'no-cache']);
    }

    if ($e instanceof HttpExceptionInterface) {
      $response = new Response($e->getMessage()$e->getStatusCode());
      $response->headers->add($e->getHeaders());
      return $response;
    }

    throw $e;
  }

  

        return rtrim($this->cacheDir, DIRECTORY_SEPARATOR);
    }

    /** * @param string $path * * @return string */
    public function formatPathToUrl($path, Shop\Shop $shop)
    {
        return str_replace([rtrim($this->rootDir, '/\\'), '\\', '//'][$shop->getBasePath(), '/', '/']$path);
    }

    /** * Returns the directory path to the compiler source map. * * @return string */
    public function getSourceMapPath()
    {
        return $this->getCacheDirectory() . DIRECTORY_SEPARATOR . 'css.source.map';
    }

    

    private function createFallbackMediaUrl()
    {
        $request = $this->container->get('front')->Request();

        if ($request && $request->getHttpHost()) {
            return ($request->isSecure() ? 'https' : 'http') . '://' . $request->getHttpHost() . $request->getBasePath() . '/';
        }

        if ($this->container->initialized('shop')) {
            $shop = $this->container->get('shop');
        } else {
            $shop = $this->container->get(ModelManager::class)->getRepository(Shop::class)->getActiveDefault();
        }

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

        
Home | Imprint | This part of the site doesn't use cookies.