getRequestUri example

private readonly array $ignoredParameters
    ) {
    }

    public function getDecorated(): AbstractHttpCacheKeyGenerator
    {
        throw new DecorationPatternException(self::class);
    }

    public function generate(Request $request): string
    {
        $uri = $this->getRequestUri($request) . $this->cacheHash;

        $event = new HttpCacheGenerateKeyEvent($request, 'md' . hash('sha256', $uri));

        $this->eventDispatcher->dispatch($event);

        $hash = $event->getHash();

        if ($request->cookies->has(CacheResponseSubscriber::CONTEXT_CACHE_COOKIE)) {
            return 'http-cache-' . hash('sha256', $hash . '-' . $request->cookies->get(CacheResponseSubscriber::CONTEXT_CACHE_COOKIE));
        }

        
/** * @return array|null */
    public function getActiveShopByRequestAsArray(Enlight_Controller_Request_Request $request)
    {
        $host = $request->getHttpHost();
        if (empty($host)) {
            return null;
        }

        $requestPath = $request->getRequestUri();

        $shops = $this->getShopsArrayByHost($host);

        // returns the right shop depending on the url         $shop = $this->findShopForRequest($shops$requestPath);

        if ($shop !== null) {
            return $shop;
        }

        return $this->getShopArrayByHostAlias($host);
    }
if ($translation) {
      $value = !empty($translation->translation) ? $translation->translation : TRUE;
    }
    else {
      // We don't have the source string, update the {locales_source} table to       // indicate the string is not translated.       $this->stringStorage->createString([
        'source' => $offset,
        'context' => $this->context,
        'version' => \Drupal::VERSION,
      ])->addLocation('path', $this->requestStack->getCurrentRequest()->getRequestUri())->save();
      $value = TRUE;
    }

    // If there is no translation available for the current language then use     // language fallback to try other translations.     if ($value === TRUE) {
      $fallbacks = $this->languageManager->getFallbackCandidates(['langcode' => $this->langcode, 'operation' => 'locale_lookup', 'data' => $offset]);
      if (!empty($fallbacks)) {
        foreach ($fallbacks as $langcode) {
          $translation = $this->stringStorage->findTranslation([
            'language' => $langcode,
            
global $base_root;
    $connection = Database::getConnection();
    // Get a count of how many watchdog entries already exist.     $count = $connection->select('watchdog')->countQuery()->execute()->fetchField();
    $log = [
      'channel'     => 'system',
      'message'     => 'Log entry added to test the doClearTest clear down.',
      'variables'   => [],
      'severity'    => RfcLogLevel::NOTICE,
      'link'        => NULL,
      'uid'         => $this->adminUser->id(),
      'request_uri' => $base_root . \Drupal::request()->getRequestUri(),
      'referer'     => \Drupal::request()->server->get('HTTP_REFERER'),
      'ip'          => '127.0.0.1',
      'timestamp'   => REQUEST_TIME,
    ];
    // Add a watchdog entry.     $this->container->get('logger.dblog')->log($log['severity']$log['message']$log);
    // Make sure the table count has actually been incremented.     $this->assertEquals($count + 1, (int) $connection->select('watchdog')->countQuery()->execute()->fetchField()new FormattableMarkup('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', [':count' => $count]));
    // Log in the admin user.     $this->drupalLogin($this->adminUser);
    // Post in order to clear the database table.
$user = !empty($this->adminUser) ? $this->adminUser : new AnonymousUserSession();

    // Prepare the fields to be logged.     $log = $options + [
      'channel'     => 'custom',
      'message'     => 'Dblog test log message',
      'variables'   => [],
      'severity'    => RfcLogLevel::NOTICE,
      'link'        => NULL,
      'uid'         => $user->id(),
      'request_uri' => $base_root . \Drupal::request()->getRequestUri(),
      'referer'     => \Drupal::request()->server->get('HTTP_REFERER'),
      'ip'          => '127.0.0.1',
      'timestamp'   => REQUEST_TIME,
    ];

    $logger = $this->container->get('logger.dblog');
    $message = $log['message'] . ' Entry #';
    for ($i = 0; $i < $count$i++) {
      $log['message'] = $message . $i;
      $logger->log($log['severity']$log['message']$log);
    }
  }
$connection = Database::getConnection();
    // Insert a row with a big value for wid.     $insert = $connection->insert('watchdog');
    $insert->fields([
      'wid'         => 2147483647000,
      'message'     => 'Dblog test log message with big WID',
      'type'        => 'test',
      'variables'   => '',
      'severity'    => RfcLogLevel::NOTICE,
      'uid'         => 1,
      'location'    => $base_root . \Drupal::request()->getRequestUri(),
      'hostname'    => $base_root,
      'timestamp'   => \Drupal::time()->getRequestTime(),
    ]);
    $insert->execute();

    // Insert another row without a value for wid, to test auto-increment.     $insert = $connection->insert('watchdog');
    $insert->fields([
      'message'     => 'Dblog test log message with big WID',
      'type'        => 'test',
      'variables'   => '',
      
use Monolog\Processor\ProcessorInterface;

class ShopwareEnvironmentProcessor implements ProcessorInterface
{
    /** * Adds request, shop and session info */
    public function __invoke(array $record)
    {
        if ($request = Shopware()->Front()->Request()) {
            $record['extra']['request'] = [
                'uri' => $request->getRequestUri(),
                'method' => $request->getMethod(),
                'query' => $this->filterRequestUserData($request->getQuery()),
                'post' => $this->filterRequestUserData($request->getPost()),
            ];
        } elseif (!empty($_SERVER['REQUEST_URI'])) {
            $record['extra']['request'] = [
                'uri' => $_SERVER['REQUEST_URI'],
                'method' => $_SERVER['REQUEST_METHOD'],
                'query' => $this->filterRequestUserData($_GET),
                'post' => $this->filterRequestUserData($_POST),
            ];
        }


        if (!empty($categoryContent['template'])) {
            if ($this->View()->templateExists('frontend/listing/' . $categoryContent['template'])) {
                $vars = $this->View()->getAssign();
                $this->View()->loadTemplate('frontend/listing/' . $categoryContent['template']);
                $this->View()->assign($vars);
            } else {
                $this->get('corelogger')->error(
                    'Missing category template detected. Please correct the template for category "' . $categoryContent['name'] . '".',
                    [
                        'uri' => $this->Request()->getRequestUri(),
                        'categoryId' => $requestCategoryId,
                        'categoryName' => $categoryContent['name'],
                    ]
                );
            }
        }

        return $categoryContent;
    }

    /** * @param array{showListing: bool} $emotionConfiguration */
/** * Builds the $form['#action']. * * @return string * The URL to be used as the $form['#action']. */
  protected function buildFormAction() {
    // @todo Use <current> instead of the main request in     // https://www.drupal.org/node/2505339.     $request = $this->requestStack->getMainRequest();
    $request_uri = $request->getRequestUri();

    // Prevent cross site requests via the Form API by using an absolute URL     // when the request uri starts with multiple slashes..     if (str_starts_with($request_uri, '//')) {
      $request_uri = $request->getUri();
    }

    // @todo Remove this parsing once these are removed from the request in     // https://www.drupal.org/node/2504709.     $parsed = UrlHelper::parse($request_uri);
    unset($parsed['query'][static::AJAX_FORM_REQUEST]$parsed['query'][MainContentViewSubscriber::WRAPPER_FORMAT]);
    

        return $this->request->getMethod();
    }

    /** * The method `uri` returns the request uri with the resolved url * * @return string request uri */
    public function uri(): string
    {
        return $this->request->attributes->get('sw-original-request-uri', $this->request->getRequestUri());
    }

    /** * The method `pathInfo` returns the request path info. The path info can be also an internal link when a seo url is used. * * @return string request path info */
    public function pathInfo(): string
    {
        return $this->request->getPathInfo();
    }

    
$exception->setAttributes($this->role);

            throw $exception;
        }

        $this->logger?->info('Attempting to switch to user.', ['username' => $username]);

        $this->userChecker->checkPostAuth($user);

        $roles = $user->getRoles();
        $roles[] = 'ROLE_PREVIOUS_ADMIN';
        $originatedFromUri = str_replace('/&', '/?', preg_replace('#[&?]'.$this->usernameParameter.'=[^&]*#', '', $request->getRequestUri()));
        $token = new SwitchUserToken($user$this->firewallName, $roles$token$originatedFromUri);

        if (null !== $this->dispatcher) {
            $switchEvent = new SwitchUserEvent($request$token->getUser()$token);
            $this->dispatcher->dispatch($switchEvent, SecurityEvents::SWITCH_USER);
            // use the token from the event in case any listeners have replaced it.             $token = $switchEvent->getToken();
        }

        return $token;
    }

    
$cookies = [];

        foreach ($this->cookies as $k => $v) {
            $cookies[] = \is_array($v) ? http_build_query([$k => $v], '', '; ', \PHP_QUERY_RFC3986) : "$k=$v";
        }

        if ($cookies) {
            $cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
        }

        return
            sprintf('%s %s %s', $this->getMethod()$this->getRequestUri()$this->server->get('SERVER_PROTOCOL'))."\r\n".
            $this->headers.
            $cookieHeader."\r\n".
            $content;
    }

    /** * Overrides the PHP global variables according to this request instance. * * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE. * $_FILES is never overridden, see rfc1867 * * @return void */
$expected = $this->container->get('backendsession')->offsetGet(self::CSRF_TOKEN_HEADER);
        if (!\is_string($expected)) {
            throw new CSRFTokenValidationException('The backend session does not contain a valid CSRF token');
        }
        $token = $controller->Request()->getHeader(self::CSRF_TOKEN_HEADER);

        if (empty($token)) {
            $token = $controller->Request()->getParam(self::CSRF_TOKEN_ARGUMENT);
        }

        if (!hash_equals($expected$token)) {
            throw new CSRFTokenValidationException(sprintf('The provided CSRF-Token is invalid. If you\'re sure that the request to path "%s" should be valid, the called controller action needs to be whitelisted using the CSRFWhitelistAware interface.', $controller->Request()->getRequestUri()));
        }
    }

    /** * CSRF protection for frontend actions * * @throws CSRFTokenValidationException */
    public function checkFrontendTokenValidation(Enlight_Event_EventArgs $args)
    {
        if (!$this->isEnabledFrontend) {
            
private function buildExitPath(string $targetUri = null): string
    {
        if (null === ($request = $this->requestStack->getCurrentRequest()) || !$this->isImpersonatedUser()) {
            return '';
        }

        if (null === $switchUserConfig = $this->firewallMap->getFirewallConfig($request)->getSwitchUser()) {
            throw new \LogicException('Unable to generate the impersonate exit URL without a firewall configured for the user switch.');
        }

        $targetUri ??= $request->getRequestUri();

        $targetUri .= (parse_url($targetUri, \PHP_URL_QUERY) ? '&' : '?').http_build_query([$switchUserConfig['parameter'] => SwitchUserListener::EXIT_VALUE], '', '&');

        return $targetUri;
    }
}

    public function init()
    {
        $this->Front()->Plugins()->ScriptRenderer()->setRender(false);
        $this->Front()->Plugins()->ViewRenderer()->setNoRender(true);
        $this->Front()->Plugins()->Json()->setRenderer(false);
    }

    public function fallbackAction()
    {
        $mediaService = $this->get(MediaServiceInterface::class);
        $requestedImage = $this->Request()->getRequestUri();

        if (!$mediaService->has($requestedImage)) {
            $this->Response()->setStatusCode(404);

            return;
        }

        $url = $mediaService->getUrl($requestedImage);
        $logger = $this->get('corelogger');
        $logger->info('Legacy media url detected.', ['requestedUrl' => $requestedImage, 'redirectedTo' => $url]);

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