class Route (View source)

Implementation of a standard route

Constants

ROUTEPART_TYPE_STATIC

ROUTEPART_TYPE_DYNAMIC

PATTERN_EXTRACTROUTEPARTS

Properties

protected string $name

Route name

protected array $defaults

Default values

protected string $uriPattern

URI Pattern of this route

protected bool $lowerCase

Specifies whether Route Parts of this Route should be converted to lower case when resolved.

protected bool $appendExceedingArguments

Specifies whether Route Values, that are not part of the Routes configuration, should be appended as query string

protected RouteTags|null $cacheTags

Specifies the tags to be associated with cache items generated by this route

protected RouteLifetime|null $cacheLifetime

Specifies the lifetime to be associated with cache items generated by this route

protected array $matchResults

Contains the routing results (indexed by "package", "controller" and "action") after a successful call of matches()

protected RouteTags|null $matchedTags

The tags that have been associated with this route during request matching, or NULL if no tags were set

protected RouteLifetime|null $matchedLifetime

The lifetime that has been associated with this route during request matching, or NULL

protected UriConstraints|null $resolvedUriConstraints

The merged UriConstraints of all Route Parts after resolving

protected RouteTags|null $resolvedTags

The tags that have been associated with this route during resolving, or NULL if no tags were set

protected RouteLifetime|null $resolvedLifetime

The lifetime that has been associated with this route during resolving, or NULL

protected array $routePartsConfiguration

Contains associative array of Route Part options (key: Route Part name, value: array of Route Part options)

protected RoutePartInterface[] $routeParts

Container for Route Parts.

protected list<string> $httpMethods

If not empty only the specified HTTP verbs are accepted by this route

protected bool $isParsed

Indicates whether this route is parsed.

protected ObjectManagerInterface $objectManager
protected PersistenceManagerInterface $persistenceManager

Methods

void
setName(string $name)

Sets Route name.

string
getName()

Returns the name of this Route.

void
setDefaults(array $defaults)

Sets default values for this Route.

array
getDefaults()

Returns default values for this Route.

void
setUriPattern(string $uriPattern)

Sets the URI pattern this route should match with

string
getUriPattern()

Returns the URI pattern this route should match with

void
setLowerCase(bool $lowerCase)

Specifies whether Route parts of this route should be converted to lower case when resolved.

bool
isLowerCase()

Getter for $this->lowerCase.

void
setAppendExceedingArguments(bool $appendExceedingArguments)

Specifies whether Route values, that are not part of the Route configuration, should be appended to the Resulting URI as query string.

bool
getAppendExceedingArguments()

Returns true if exceeding arguments should be appended to the URI as query string, otherwise false

void
setRoutePartsConfiguration(array $routePartsConfiguration)

By default all Dynamic Route Parts are resolved by \Neos\Flow\Mvc\Routing\DynamicRoutePart.

array
getRoutePartsConfiguration()

Returns the route parts configuration of this route

void
setHttpMethods(array $httpMethods)

Limits the HTTP verbs that are accepted by this route.

array
getHttpMethods()

No description

void
setCacheTags(RouteTags|null $tags)

Tags for cache items

void
setCacheLifetime(RouteLifetime|null $lifetime)

Lifetime for cache items

bool
hasHttpMethodConstraints()

Whether or not this route is limited to one or more HTTP verbs

array
getMatchResults()

Returns an array with the Route match results.

RouteTags|null
getMatchedTags()

Returns the tags that have been associated with this route during request matching, or NULL if no tags were set

RouteLifetime|null
getMatchedLifetime()

Returns the lifetime been associated with this route during request matching, or NULL

getResolvedUriConstraints()

Returns the merged UriConstraints of all Route Parts after resolving, or NULL if no constraints were set yet

RouteTags|null
getResolvedTags()

Returns the tags that have been associated with this route during resolving, or NULL if no tags were set

RouteLifetime|null
getResolvedLifetime()

Returns the tags that have been associated with this route during resolving, or NULL if no tags were set

bool
matches(RouteContext $routeContext)

Checks whether $routeContext corresponds to this Route.

bool
resolves(ResolveContext $resolveContext)

Checks whether $routeValues can be resolved to a corresponding uri.

bool
compareAndRemoveMatchingDefaultValues(array $defaults, array $routeValues)

Recursively iterates through the defaults of this route.

array
extractInternalArguments(array $arguments)

Removes all internal arguments (prefixed with two underscores) from the given $arguments and returns them as array

bool
containsObject(mixed $subject)

Checks if the given subject contains an object

void
parse()

Iterates through all segments in $this->uriPattern and creates appropriate RoutePart instances.

Details

void setName(string $name)

Sets Route name.

Parameters

string $name

The Route name

Return Value

void

string getName()

Returns the name of this Route.

Return Value

string

Route name.

void setDefaults(array $defaults)

Sets default values for this Route.

This array is merged with the actual matchResults when match() is called.

Parameters

array $defaults

Return Value

void

array getDefaults()

Returns default values for this Route.

Return Value

array

Route defaults

void setUriPattern(string $uriPattern)

Sets the URI pattern this route should match with

Parameters

string $uriPattern

Return Value

void

Exceptions

InvalidArgumentException

string getUriPattern()

Returns the URI pattern this route should match with

Return Value

string

the URI pattern

void setLowerCase(bool $lowerCase)

Specifies whether Route parts of this route should be converted to lower case when resolved.

This setting can be overwritten for all dynamic Route parts.

Parameters

bool $lowerCase

true: Route parts are converted to lower case by default. false: Route parts are not altered.

Return Value

void

bool isLowerCase()

Getter for $this->lowerCase.

Return Value

bool

true if this Route part will be converted to lower case, otherwise false.

See also

setLowerCase()

void setAppendExceedingArguments(bool $appendExceedingArguments)

Specifies whether Route values, that are not part of the Route configuration, should be appended to the Resulting URI as query string.

If set to false, the route won't resolve if there are route values left after iterating through all Route Part handlers and removing the matching default values.

Parameters

bool $appendExceedingArguments

true: exceeding arguments will be appended to the resulting URI

Return Value

void

bool getAppendExceedingArguments()

Returns true if exceeding arguments should be appended to the URI as query string, otherwise false

Return Value

bool

void setRoutePartsConfiguration(array $routePartsConfiguration)

By default all Dynamic Route Parts are resolved by \Neos\Flow\Mvc\Routing\DynamicRoutePart.

But you can specify different classes to handle particular Route Parts.

Note: Route Part handlers must implement \Neos\Flow\Mvc\Routing\DynamicRoutePartInterface.

Usage: setRoutePartsConfiguration(array('@controller' => array('handler' => \Neos\Package\Subpackage\MyRoutePartHandler::class)));

Parameters

array $routePartsConfiguration

Route Parts configuration options

Return Value

void

array getRoutePartsConfiguration()

Returns the route parts configuration of this route

Return Value

array $routePartsConfiguration

void setHttpMethods(array $httpMethods)

Limits the HTTP verbs that are accepted by this route.

If empty all HTTP verbs are accepted

Parameters

array $httpMethods

non-associative array in the format array('GET', 'POST', ...)

Return Value

void

array getHttpMethods()

No description

Return Value

array

void setCacheTags(RouteTags|null $tags)

Tags for cache items

Parameters

RouteTags|null $tags

Return Value

void

void setCacheLifetime(RouteLifetime|null $lifetime)

Lifetime for cache items

Parameters

RouteLifetime|null $lifetime

Return Value

void

bool hasHttpMethodConstraints()

Whether or not this route is limited to one or more HTTP verbs

Return Value

bool

array getMatchResults()

Returns an array with the Route match results.

Return Value

array

An array of Route Parts and their values for further handling by the Router

See also

Router

RouteTags|null getMatchedTags()

Returns the tags that have been associated with this route during request matching, or NULL if no tags were set

Return Value

RouteTags|null

RouteLifetime|null getMatchedLifetime()

Returns the lifetime been associated with this route during request matching, or NULL

Return Value

RouteLifetime|null

UriConstraints|null getResolvedUriConstraints()

Returns the merged UriConstraints of all Route Parts after resolving, or NULL if no constraints were set yet

Return Value

UriConstraints|null

RouteTags|null getResolvedTags()

Returns the tags that have been associated with this route during resolving, or NULL if no tags were set

Return Value

RouteTags|null

RouteLifetime|null getResolvedLifetime()

Returns the tags that have been associated with this route during resolving, or NULL if no tags were set

Return Value

RouteLifetime|null

bool matches(RouteContext $routeContext)

Checks whether $routeContext corresponds to this Route.

If all Route Parts match successfully true is returned an $this->matchResults contains an array combining Route default values and calculated matchResults from the individual Route Parts.

Parameters

RouteContext $routeContext

The Route Context containing the current HTTP request object and, optional, Routing RouteParameters

Return Value

bool

true if this Route corresponds to the given $routeContext, otherwise false

Exceptions

InvalidRoutePartValueException

See also

getMatchResults()

bool resolves(ResolveContext $resolveContext)

Checks whether $routeValues can be resolved to a corresponding uri.

If all Route Parts can resolve one or more of the $routeValues, true is returned and $this->resolvedUriConstraints contains an instance of UriConstraints that can be applied to a template URI transforming it accordingly (Router::resolve())

Parameters

ResolveContext $resolveContext

context for this resolve invokation

Return Value

bool

true if this Route corresponds to the given $routeValues, otherwise false

Exceptions

InvalidRoutePartValueException

protected bool compareAndRemoveMatchingDefaultValues(array $defaults, array $routeValues)

Recursively iterates through the defaults of this route.

If a route value is equal to a default value, it's removed from $routeValues. If a value exists but is not equal to is corresponding default, iteration is interrupted and false is returned.

Parameters

array $defaults
array $routeValues

Return Value

bool

false if one of the $routeValues is not equal to it's default value. Otherwise true

protected array extractInternalArguments(array $arguments)

Removes all internal arguments (prefixed with two underscores) from the given $arguments and returns them as array

Parameters

array $arguments

Return Value

array

the internal arguments

protected bool containsObject(mixed $subject)

Checks if the given subject contains an object

Parameters

mixed $subject

Return Value

bool

If it contains an object or not

void parse()

Iterates through all segments in $this->uriPattern and creates appropriate RoutePart instances.

Return Value

void

Exceptions

InvalidUriPatternException