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
$backendEntryPointResolver read-only
protected
BackendEntryPointResolver
$backendEntryPointResolver
$requestContextFactory read-only
protected
RequestContextFactory
$requestContextFactory
$routeCollection
All routes used in the TYPO3 Backend
protected
RouteCollection
$routeCollection
Methods
__construct()
public
__construct(RequestContextFactory $requestContextFactory, BackendEntryPointResolver $backendEntryPointResolver) : mixed
Parameters
- $requestContextFactory : RequestContextFactory
- $backendEntryPointResolver : BackendEntryPointResolver
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> = []
addRouteCollection()
public
addRouteCollection(RouteCollection $routeCollection) : void
Parameters
- $routeCollection : RouteCollection
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|nullgetRouteCollection()
public
getRouteCollection() : RouteCollection
only use in Core, this should not be exposed
Return values
RouteCollectiongetRoutes()
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
boolmatch()
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
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