‪TYPO3CMS  9.5
BackendRouteInitialization.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
20 use Psr\Http\Server\MiddlewareInterface;
21 use Psr\Http\Server\RequestHandlerInterface;
25 
34 class ‪BackendRouteInitialization implements MiddlewareInterface
35 {
43  public function ‪process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
44  {
45  // Check if a module URL is requested and deprecate this call
46  $moduleName = $request->getQueryParams()['M'] ?? $request->getParsedBody()['M'] ?? null;
47  // Allow the login page to be displayed if routing is not used and on index.php
48  // (consolidate RouteDispatcher::evaluateReferrer() when changing 'login' to something different)
49  $pathToRoute = $request->getQueryParams()['route'] ?? $request->getParsedBody()['route'] ?? $moduleName ?? '/login';
50 
51  if ($moduleName !== null) {
52  // backwards compatibility for old module names
53  // @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
54  $router = GeneralUtility::makeInstance(Router::class);
55  foreach ($router->getRoutes() as $routeIdentifier => $route) {
56  if ($routeIdentifier === $moduleName) {
57  $pathToRoute = $route->getPath();
58  break;
59  }
60  }
61 
62  trigger_error('Calling the TYPO3 Backend with "M" GET parameter will be removed in TYPO3 v10.0,'
63  . ' the calling code calls this script with "&M=' . $moduleName . '" and needs to be adapted'
64  . ' to use the TYPO3 API.', E_USER_DEPRECATED);
65  }
66 
69 
70  // Add the route path to the request
71  $request = $request->withAttribute('routePath', $pathToRoute);
72 
73  return $handler->handle($request);
74  }
75 }
‪TYPO3\CMS\Backend\Middleware\BackendRouteInitialization\process
‪ResponseInterface process(ServerRequestInterface $request, RequestHandlerInterface $handler)
Definition: BackendRouteInitialization.php:43
‪TYPO3\CMS\Backend\Middleware
Definition: AdditionalResponseHeaders.php:3
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendRouter
‪static Bootstrap null initializeBackendRouter()
Definition: Bootstrap.php:898
‪TYPO3\CMS\Backend\Middleware\BackendRouteInitialization
Definition: BackendRouteInitialization.php:35
‪TYPO3\CMS\Core\Core\Bootstrap\loadExtTables
‪static Bootstrap null loadExtTables(bool $allowCaching=true)
Definition: Bootstrap.php:864
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Routing\Router
Definition: Router.php:32