Router implements SingletonInterface

Implementation of a class for adding routes, collecting throughout the Bootstrap to register all sorts of Backend Routes, and to fetch the main Collection in order to resolve a route (see ->match() and ->matchRequest()).

Ideally, the Router is solely instantiated and accessed via the Bootstrap, the RequestHandler and the UriBuilder.

See \TYPO3\CMS\Backend\Http\RequestHandler for more details on route matching() and Bootstrap->initializeBackendRouting().

The architecture is inspired by the Symfony Routing Component.

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$backendEntryPointResolver  : BackendEntryPointResolver
$requestContextFactory  : RequestContextFactory
$routeCollection  : RouteCollection
All routes used in the TYPO3 Backend

Methods

__construct()  : mixed
addRoute()  : void
Adds a new route with a given identifier
addRouteCollection()  : void
getRoute()  : Route|Route|null
Returns a route by its identifier, or null if nothing found.
getRouteCollection()  : RouteCollection
getRoutes()  : array<string|int, Route>
Fetch all registered routes, only use in UriBuilder. Does not care about aliases, so be careful with using this method.
hasRoute()  : bool
match()  : Route
Tries to match a URL path with a set of routes.
matchRequest()  : Route
Tries to match a URI against the registered routes.
matchResult()  : RouteResult
Matches a PSR-7 Request and returns a RouteResult with parameters and the resolved route.

Properties

Methods

addRoute()

Adds a new route with a given identifier

public addRoute(string $routeIdentifier, Route $route[, array<string|int, mixed> $aliases = [] ]) : void
Parameters
$routeIdentifier : string
$route : Route
$aliases : array<string|int, mixed> = []

getRoute()

Returns a route by its identifier, or null if nothing found.

public getRoute(string $routeName) : Route|Route|null
Parameters
$routeName : string
Return values
Route|Route|null

getRoutes()

Fetch all registered routes, only use in UriBuilder. Does not care about aliases, so be careful with using this method.

public getRoutes() : array<string|int, Route>
Return values
array<string|int, Route>

hasRoute()

public hasRoute(string $routeName) : bool
Parameters
$routeName : string
Return values
bool

match()

Tries to match a URL path with a set of routes.

public match(string $pathInfo) : Route
Parameters
$pathInfo : string

The path info to be parsed

Tags
throws
ResourceNotFoundException

If the resource could not be found

Return values
Route

the first Route object found

matchRequest()

Tries to match a URI against the registered routes.

public matchRequest(ServerRequestInterface $request) : Route

Use ->matchResult() instead, as this method will be deprecated in the future.

Parameters
$request : ServerRequestInterface
Return values
Route

the first Route object found

matchResult()

Matches a PSR-7 Request and returns a RouteResult with parameters and the resolved route.

public matchResult(ServerRequestInterface $request) : RouteResult
Parameters
$request : ServerRequestInterface
Return values
RouteResult

        
On this page

Search results