class PathProcessorManager implements InboundPathProcessorInterface, OutboundPathProcessorInterface (View source)

Path processor manager.

Holds an array of path processor objects and uses them to sequentially process a path, in order of processor priority.

Properties

protected array $inboundProcessors

Holds the array of inbound processors to cycle through.

protected array $sortedInbound

Holds the array of inbound processors, sorted by priority.

protected array $outboundProcessors

Holds the array of outbound processors to cycle through.

protected array $sortedOutbound

Holds the array of outbound processors, sorted by priority.

Methods

addInbound(InboundPathProcessorInterface $processor, int $priority = 0)

Adds an inbound processor object to the $inboundProcessors property.

string
processInbound(string $path, Request $request)

Processes the inbound path.

array
getInbound()

Returns the sorted array of inbound processors.

addOutbound(OutboundPathProcessorInterface $processor, int $priority = 0)

Adds an outbound processor object to the $outboundProcessors property.

string
processOutbound(string $path, array $options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL)

Processes the outbound path.

array
getOutbound()

Returns the sorted array of outbound processors.

sortProcessors(string $type)

Sorts the processors according to priority.

Details

addInbound(InboundPathProcessorInterface $processor, int $priority = 0)

Adds an inbound processor object to the $inboundProcessors property.

Parameters

InboundPathProcessorInterface $processor

The processor object to add.

int $priority

The priority of the processor being added.

string processInbound(string $path, Request $request)

Processes the inbound path.

Implementations may make changes to the request object passed in but should avoid all other side effects. This method can be called to process requests other than the current request.

Parameters

string $path

The path to process, with a leading slash.

Request $request

The HttpRequest object representing the request to process. Note, if this method is being called via the path_processor_manager service and is not part of routing, the current request object must be cloned before being passed in.

Return Value

string

The processed path.

protected array getInbound()

Returns the sorted array of inbound processors.

Return Value

array

An array of processor objects.

addOutbound(OutboundPathProcessorInterface $processor, int $priority = 0)

Adds an outbound processor object to the $outboundProcessors property.

Parameters

OutboundPathProcessorInterface $processor

The processor object to add.

int $priority

The priority of the processor being added.

string processOutbound(string $path, array $options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL)

Processes the outbound path.

Parameters

string $path

The path to process, with a leading slash.

array $options

(optional) An associative array of additional options, with the following elements:

  • 'query': An array of query key/value-pairs (without any URL-encoding) to append to the URL.
  • 'fragment': A fragment identifier (named anchor) to append to the URL. Do not include the leading '#' character.
  • 'absolute': Defaults to FALSE. Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed.
  • 'language': An optional language object used to look up the alias for the URL. If $options['language'] is omitted, it defaults to the current language for the language type LanguageInterface::TYPE_URL.
  • 'https': Whether this URL should point to a secure location. If not defined, the current scheme is used, so the user stays on HTTP or HTTPS respectively. TRUE enforces HTTPS and FALSE enforces HTTP.
  • 'base_url': Only used internally by a path processor, for example, to modify the base URL when a language dependent URL requires so.
  • 'prefix': Only used internally, to modify the path when a language dependent URL requires so.
  • 'route': The route object for the given path. It will be set by \Drupal\Core\Routing\UrlGenerator::generateFromRoute().
Request $request

The HttpRequest object representing the current request.

BubbleableMetadata $bubbleable_metadata

(optional) Object to collect path processors' bubbleable metadata.

Return Value

string

The processed path.

protected array getOutbound()

Returns the sorted array of outbound processors.

Return Value

array

An array of processor objects.

protected sortProcessors(string $type)

Sorts the processors according to priority.

Parameters

string $type

The processor type to sort, e.g. 'inboundProcessors'.