getRoute example



        /** @var array<string, Error[]> $groups */
        foreach ($groups as $type => $errors) {
            foreach ($errors as $error) {
                $parameters = [];

                foreach ($error->getParameters() as $key => $value) {
                    $parameters['%' . $key . '%'] = $value;
                }

                if ($error->getRoute() instanceof ErrorRoute) {
                    $parameters['%url%'] = $this->generateUrl(
                        $error->getRoute()->getKey(),
                        $error->getRoute()->getParams()
                    );
                }

                $message = $this->trans('checkout.' . $error->getMessageKey()$parameters);

                if (\in_array($message$flat, true)) {
                    continue;
                }

                
/** * {@inheritdoc} */
  public function isStrictRequirements() {
    return TRUE;
  }

  /** * {@inheritdoc} */
  public function getPathFromRoute($name$parameters = []) {
    $route = $this->getRoute($name);
    if (!is_string($name)) {
      @trigger_error('Passing a route object to ' . __METHOD__ . '() is deprecated in drupal:10.1.0 and will not be supported in drupal:11.0.0. Pass the route name instead. See https://www.drupal.org/node/3172280', E_USER_DEPRECATED);
      $name = $this->getRouteStringIdentifier($name);
    }
    $this->processRoute($name$route$parameters);
    $path = $this->getInternalPathFromRoute($name$route$parameters);
    // Router-based paths may have a querystring on them but Drupal paths may     // not have one, so remove any ? and anything after it. For generate() this     // is handled in processPath().     $path = preg_replace('/\?.*/', '', $path);
    return trim($path, '/');
  }
$attributes = $c->getRequestAttributes();

        $this->assertSame('request', $c->getName());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestHeaders());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestServer());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestCookies());
        $this->assertInstanceOf(ParameterBag::class$attributes);
        $this->assertInstanceOf(ParameterBag::class$c->getRequestRequest());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestQuery());
        $this->assertInstanceOf(ParameterBag::class$c->getResponseCookies());
        $this->assertSame('html', $c->getFormat());
        $this->assertEquals('foobar', $c->getRoute());
        $this->assertEquals(['name' => 'foo']$c->getRouteParams());
        $this->assertSame([]$c->getSessionAttributes());
        $this->assertSame('en', $c->getLocale());
        $this->assertContainsEquals(__FILE__, $attributes->get('resource'));
        $this->assertSame('stdClass', $attributes->get('object')->getType());

        $this->assertInstanceOf(ParameterBag::class$c->getResponseHeaders());
        $this->assertSame('OK', $c->getStatusText());
        $this->assertSame(200, $c->getStatusCode());
        $this->assertSame('application/json', $c->getContentType());
    }

    
$params['controller'] = $params['sViewport'];
        }

        $context->setParams($params);

        // /widgets and /index supports short request queries         if ($pathInfo === '/' || str_starts_with($pathInfo, '/widgets/')) {
            return $pathInfo;
        }

        $pathInfo = ltrim($pathInfo, '/');
        $route = $this->getRoute($shopId$pathInfo);

        if (!\is_array($route)) {
            return $pathInfo;
        }

        $query = $this->getQueryFormOrgPath($route['orgPath']);
        if (empty($route['main']) || (int) $route['shopId'] !== $shopId) {
            $query['rewriteAlias'] = true;
        } else {
            $query['rewriteUrl'] = true;
        }

        
/** * Checks Auto Routes. * * Attempts to match a URI path against Controllers and directories * found in APPPATH/Controllers, to find a matching route. * * @return void */
    public function autoRoute(string $uri)
    {
        [$this->directory, $this->controller, $this->method, $this->params]
            = $this->autoRouter->getRoute($uri$this->collection->getHTTPVerb());
    }

    /** * Scans the controller directory, attempting to locate a controller matching the supplied uri $segments * * @param array $segments URI segments * * @return array returns an array of remaining uri segments that don't map onto a directory * * @deprecated this function name does not properly describe its behavior so it has been deprecated * * @codeCoverageIgnore */
$container->get('router.route_provider'),
      $container->get('state'),
      $container->get('entity_type.manager')->getStorage('menu'),
      $container->get('menu.parent_form_selector')
    );
  }

  /** * {@inheritdoc} */
  protected function getRoute($view_id$display_id) {
    $route = parent::getRoute($view_id$display_id);

    // Explicitly set HTML as the format for Page displays.     $route->setRequirement('_format', 'html');

    if ($this->getOption('use_admin_theme')) {
      $route->setOption('_admin_route', TRUE);
    }

    return $route;
  }

  
return $route;
  }

  /** * {@inheritdoc} */
  public function collectRoutes(RouteCollection $collection) {
    $view_id = $this->view->storage->id();
    $display_id = $this->display['id'];

    $route = $this->getRoute($view_id$display_id);

    if (!($route_name = $this->getOption('route_name'))) {
      $route_name = "view.$view_id.$display_id";
    }
    $collection->add($route_name$route);
    return ["$view_id.$display_id" => $route_name];
  }

  /** * Determines whether the view overrides the given route. * * @param string $view_path * The path of the view. * @param \Symfony\Component\Routing\Route $view_route * The route of the view. * @param \Symfony\Component\Routing\Route $route * The route itself. * * @return bool * TRUE, when the view should override the given route. */

#[Package('storefront')] class StorefrontRedirectEventTest extends TestCase
{
    public function testMinimalConstructor(): void
    {
        $event = new StorefrontRedirectEvent('test_route');

        static::assertSame('test_route', $event->getRoute());
        static::assertSame([]$event->getParameters());
        static::assertSame(Response::HTTP_FOUND, $event->getStatus());
    }

    public function testConstructor(): void
    {
        $event = new StorefrontRedirectEvent('test_route', ['test_parameter' => 'test_value'], 500);

        static::assertSame('test_route', $event->getRoute());
        static::assertSame(['test_parameter' => 'test_value']$event->getParameters());
        static::assertSame(500, $event->getStatus());
    }
public function load(HreflangLoaderParameter $parameter): HreflangCollection
    {
        $salesChannelContext = $parameter->getSalesChannelContext();

        if (!$salesChannelContext->getSalesChannel()->isHreflangActive()) {
            return new HreflangCollection();
        }

        $domains = $this->fetchSalesChannelDomains($salesChannelContext->getSalesChannel()->getId());

        if ($parameter->getRoute() === 'frontend.home.page') {
            return $this->getHreflangForHomepage($domains$salesChannelContext->getSalesChannel()->getHreflangDefaultDomainId());
        }

        $pathInfo = $this->router->generate($parameter->getRoute()$parameter->getRouteParameters(), RouterInterface::ABSOLUTE_PATH);

        $languageToDomainMapping = $this->getLanguageToDomainMapping($domains);
        $seoUrls = $this->fetchSeoUrls($pathInfo$salesChannelContext->getSalesChannel()->getId()array_keys($languageToDomainMapping));

        // We need at least two links         if (\count($seoUrls) <= 1) {
            return new HreflangCollection();
        }


    public function __invoke(WarmUpMessage $message): void
    {
        if ($this->cacheIdLoader->load() !== $message->getCacheId()) {
            return;
        }

        $kernel = $this->createHttpCacheKernel($message->getCacheId());

        foreach ($message->getParameters() as $parameters) {
            $url = rtrim($message->getDomain(), '/') . $this->router->generate($message->getRoute()$parameters);

            $request = $this->requestTransformer->transform(Request::create($url));

            $kernel->handle($request);

            // the cache tag collection, collects all cache tags for a single request,             // after the request handled, the collection has to be reset for the next request             $this->cacheTagCollection->reset();
        }
    }

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