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