PageTypeDecorator

class \TYPO3\CMS\Core\Routing\Enhancer\PageTypeDecorator

Extends
AbstractEnhancer
Implements
DecoratingEnhancerInterface

Resolves a static list (like page.typeNum) against a file pattern. Usually added on the very last part of the URL.

It is important that the PageType Enhancer is executed at the very end in your configuration, as it modifies EXISTING route variants.

routeEnhancers: PageTypeSuffix: type: PageType default: '' index: 'index' map: '.html': 1 'menu.json': 13

Table of Contents

Interfaces

DecoratingEnhancerInterface
Decorates a route (or routes within a collection) with additional parameters.

Constants

ROUTE_PATH_DELIMITERS  : mixed = ['.', '-', '_', '/']

Properties

$aspects  : AspectInterface[]
$configuration  : array
$default  : string
$index  : string
$map  : array
$variableProcessor  : VariableProcessor|null

Methods

__construct()  : mixed
decorateForGeneration()  : void
Decorates route collection during URL URL generation.
decorateForMatching()  : void
Decorates route collection to be processed during URL resolving.
getAspects()  : AspectInterface[]
getRoutePathRedecorationPattern()  : string
Gets pattern that can be used to redecorate (undecorate) a potential previously decorated route path.
setAspects()  : void
applyRequirements()  : mixed
applyRouteAspects()  : mixed
buildRegularExpressionPattern()  : string
Builds a regexp out of the map.
defineValuesByAspect()  : array
Define items having an aspect definition in case they are not defined with a given $targetValue in target $targetValue array.
filterValuesByPathVariables()  : array
Only keeps values that actually have been used as variables in route path.
getVariableProcessor()  : VariableProcessor
modifyRoutePath()  : string
Modify the route path to add the variable names with the aspects, e.g.
needsSlashPrefix()  : bool
Checks if a slash should be prefixed.
overrideValuesByAspect()  : array
Overrides items having an aspect definition with a given $overrideValue in target $targetValue array.
quoteForRegularExpressionPattern()  : string
Helper method for regexps.
resolveType()  : string
Retrieves type from processed route and modifies remaining query parameters.
resolveValue()  : string
Checks if the value exists inside the map.

Constants

ROUTE_PATH_DELIMITERS

protected mixed ROUTE_PATH_DELIMITERS = ['.', '-', '_', '/']

Properties

$configuration

protected array $configuration

Methods

__construct()

public __construct(array $configuration) : mixed

Parameters

$configuration : array

decorateForGeneration()

Decorates route collection during URL URL generation.

public decorateForGeneration(RouteCollection $collection, array $parameters) : void

Parameters

$collection : RouteCollection
$parameters : array

query parameters

decorateForMatching()

Decorates route collection to be processed during URL resolving.

public decorateForMatching(RouteCollection $collection, string $routePath) : void

Parameters

$collection : RouteCollection
$routePath : string

URL path

getRoutePathRedecorationPattern()

Gets pattern that can be used to redecorate (undecorate) a potential previously decorated route path.

public getRoutePathRedecorationPattern() : string

Example:

  • route path: 'first/second.html'
  • redecoration pattern: '(?:.html|.json)$' -> 'first/second' might be the redecorated route path after applying the redecoration pattern to preg_match/preg_replace

Return values

string —

regular expression pattern

setAspects()

public setAspects(array $aspects) : void

Parameters

$aspects : array

applyRequirements()

protected applyRequirements(Route $route, array $requirements[, string|null $namespace = null ]) : mixed

Parameters

$route : Route
$requirements : array
$namespace : string|null = null

buildRegularExpressionPattern()

Builds a regexp out of the map.

protected buildRegularExpressionPattern([bool $useNames = true ]) : string

Parameters

$useNames : bool = true

Return values

string

defineValuesByAspect()

Define items having an aspect definition in case they are not defined with a given $targetValue in target $targetValue array.

protected defineValuesByAspect(Route $route, array $values, string $targetValue) : array

Parameters

$route : Route
$values : array
$targetValue : string

Return values

array

filterValuesByPathVariables()

Only keeps values that actually have been used as variables in route path.

protected filterValuesByPathVariables(Route $route, array $values) : array
  • routePath: '/list/{page}' ('page' used as variable in route path)
  • values: ['entity' => 'entity...', 'page' => 'page...', 'other' => 'other...']
  • result: ['page' => 'page...']

Parameters

$route : Route
$values : array

Return values

array

modifyRoutePath()

Modify the route path to add the variable names with the aspects, e.g.

protected modifyRoutePath(string $routePath) : string
  • /{locale_modifier}/{product_title} -> /products/{product_title}
  • /{!locale_modifier}/{product_title} -> /products/{product_title}

Parameters

$routePath : string

Return values

string

needsSlashPrefix()

Checks if a slash should be prefixed.

protected needsSlashPrefix(string $value) : bool

Parameters

$value : string

Return values

bool

overrideValuesByAspect()

Overrides items having an aspect definition with a given $overrideValue in target $targetValue array.

protected overrideValuesByAspect(Route $route, array $values, string $targetValue) : array

Parameters

$route : Route
$values : array
$targetValue : string

Return values

array

quoteForRegularExpressionPattern()

Helper method for regexps.

protected quoteForRegularExpressionPattern(string $value) : string

Parameters

$value : string

Return values

string

resolveType()

Retrieves type from processed route and modifies remaining query parameters.

protected resolveType(Route $route, array &$remainingQueryParameters) : string

Parameters

$route : Route
$remainingQueryParameters : array

reference to remaining query parameters

Return values

string

resolveValue()

Checks if the value exists inside the map.

protected resolveValue(string|null $type) : string

Parameters

$type : string|null

Return values

string
On this page