function UrlGenerator::__construct

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Routing/UrlGenerator.php \Drupal\Core\Routing\UrlGenerator::__construct()
  2. 10 core/lib/Drupal/Core/Routing/UrlGenerator.php \Drupal\Core\Routing\UrlGenerator::__construct()
  3. 9 core/lib/Drupal/Core/Routing/UrlGenerator.php \Drupal\Core\Routing\UrlGenerator::__construct()
  4. 8.9.x core/lib/Drupal/Core/Routing/UrlGenerator.php \Drupal\Core\Routing\UrlGenerator::__construct()

Constructs a new generator object.

Parameters

\Drupal\Core\Routing\RouteProviderInterface $provider: The route provider to be searched for routes.

\Drupal\Core\PathProcessor\OutboundPathProcessorInterface $pathProcessor: The path processor to convert the system path to one suitable for URLs.

\Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface $routeProcessor: The route processor.

\Symfony\Component\HttpFoundation\RequestStack $requestStack: A request stack object.

string[] $filter_protocols: (optional) An array of protocols allowed for URL generation.

1 method overrides UrlGenerator::__construct()
NullGenerator::__construct in core/lib/Drupal/Core/Routing/NullGenerator.php
Override the parent constructor.

File

core/lib/Drupal/Core/Routing/UrlGenerator.php, line 62

Class

UrlGenerator
Generates URLs from route names and parameters.

Namespace

Drupal\Core\Routing

Code

public function __construct(protected RouteProviderInterface $provider, protected OutboundPathProcessorInterface $pathProcessor, protected OutboundRouteProcessorInterface $routeProcessor, protected RequestStack $requestStack, array $filter_protocols = [
  'http',
  'https',
]) {
  $this->context = new RequestContext();
  UrlHelper::setAllowedProtocols($filter_protocols);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.