UrlGenerator
class UrlGenerator implements UrlGeneratorInterface (View source)
Generates URLs from route names and parameters.
Properties
| protected RouteProviderInterface | $provider | The route provider. |
|
| protected RequestContext | $context | ||
| protected RequestStack | $requestStack | A request stack object. |
|
| protected OutboundPathProcessorInterface | $pathProcessor | The path processor to convert the system path to one suitable for urls. |
|
| protected OutboundRouteProcessorInterface | $routeProcessor | The route processor. |
|
| protected | $decodedChars | Overrides characters that will not be percent-encoded in the path segment. |
Methods
Constructs a new generator object.
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
Gets the internal path (system path) for a route.
Substitute the route parameters into the route path.
Gets the path of a route.
{@inheritdoc}
Generates a URL or path for a specific route based on the given parameters.
Passes the path to a processor manager to allow alterations.
Passes the route to the processor manager for altering before compilation.
Find the route using the provided route name.
{@inheritdoc}
{@inheritdoc}
Details
__construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, RequestStack $request_stack, array $filter_protocols = ['http', 'https'])
Constructs a new generator object.
setContext(RequestContext $context)
{@inheritdoc}
getContext()
{@inheritdoc}
setStrictRequirements($enabled)
{@inheritdoc}
isStrictRequirements()
{@inheritdoc}
string
getPathFromRoute(string|Route $name, array $parameters = [])
Gets the internal path (system path) for a route.
protected string
doGenerate(array $variables, array $defaults, array $tokens, array $parameters, array $query_params, string $name)
Substitute the route parameters into the route path.
Note: This code was copied from \Symfony\Component\Routing\Generator\UrlGenerator::doGenerate() and shortened by removing code that is not relevant to Drupal or that is handled separately in ::generateFromRoute(). The Symfony version should be examined for changes in new Symfony releases.
protected string
getInternalPathFromRoute($name, Route $route, array $parameters = [], array $query_params = [])
Gets the path of a route.
generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
{@inheritdoc}
string|GeneratedUrl
generateFromRoute(string|Route $name, array $parameters = [], array $options = [], bool $collect_bubbleable_metadata = FALSE)
Generates a URL or path for a specific route based on the given parameters.
Parameters that reference placeholders in the route pattern will be substituted for them in the pattern. Extra params are added as query strings to the URL.
protected
processPath($path, $options = [], BubbleableMetadata $bubbleable_metadata = NULL)
Passes the path to a processor manager to allow alterations.
protected
processRoute(string $name, Route $route, array $parameters, BubbleableMetadata $bubbleable_metadata = NULL)
Passes the route to the processor manager for altering before compilation.
protected Route
getRoute(string|Route $name)
Find the route using the provided route name.
supports($name)
{@inheritdoc}
getRouteDebugMessage($name, array $parameters = [])
{@inheritdoc}