‪TYPO3CMS  9.5
Router.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use Psr\Http\Message\ServerRequestInterface;
19 
32 {
38  protected ‪$routes = [];
39 
46  public function ‪addRoute($routeIdentifier, $route)
47  {
48  $this->routes[$routeIdentifier] = $route;
49  }
50 
56  public function ‪getRoutes()
57  {
58  return ‪$this->routes;
59  }
60 
68  public function ‪match($pathInfo)
69  {
70  foreach ($this->routes as $routeIdentifier => $route) {
71  // This check is done in a simple way as there are no parameters yet (get parameters only)
72  if ($route->getPath() === $pathInfo) {
73  // Store the name of the Route in the _identifier option so the token can be checked against that
74  $route->‪setOption('_identifier', $routeIdentifier);
75  return $route;
76  }
77  }
78  throw new ‪ResourceNotFoundException('The requested resource "' . $pathInfo . '" was not found.', 1425389240);
79  }
80 
87  public function ‪matchRequest(ServerRequestInterface $request)
88  {
89  return $this->‪match($request->getAttribute('routePath'));
90  }
91 }
‪TYPO3\CMS\Backend\Routing\Router\addRoute
‪addRoute($routeIdentifier, $route)
Definition: Router.php:45
‪TYPO3\CMS\Backend\Routing\Route
Definition: Route.php:23
‪TYPO3\CMS\Backend\Routing\Router\matchRequest
‪Route matchRequest(ServerRequestInterface $request)
Definition: Router.php:86
‪TYPO3\CMS\Backend\Routing\Router\$routes
‪Route[] $routes
Definition: Router.php:37
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Backend\Routing\Exception\ResourceNotFoundException
Definition: ResourceNotFoundException.php:21
‪TYPO3\CMS\Backend\Routing\Router\match
‪Route match($pathInfo)
Definition: Router.php:67
‪TYPO3\CMS\Backend\Routing\Route\setOption
‪Route setOption($name, $value)
Definition: Route.php:102
‪TYPO3\CMS\Backend\Routing\Router\getRoutes
‪Route[] getRoutes()
Definition: Router.php:55
‪TYPO3\CMS\Backend\Routing\Router
Definition: Router.php:32
‪TYPO3\CMS\Backend\Routing