TYPO3 CMS  TYPO3_8-7
RequestHandler.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Http;
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 
24 
37 {
42  protected $bootstrap;
43 
49  public function __construct(Bootstrap $bootstrap)
50  {
51  $this->bootstrap = $bootstrap;
52  }
53 
60  public function handleRequest(ServerRequestInterface $request)
61  {
62  // Allow the login page to be displayed if routing is not used and on index.php
63  $pathToRoute = (string)$request->getQueryParams()['route'] ?: '/login';
64  $request = $request->withAttribute('routePath', $pathToRoute);
65 
66  // skip the BE user check on the login page
67  // should be handled differently in the future by checking the Bootstrap directly
68  $this->boot($pathToRoute === '/login');
69 
70  // Check if the router has the available route and dispatch.
71  try {
72  return $this->dispatch($request);
73  } catch (InvalidRequestTokenException $e) {
74  // When token was invalid redirect to login
75  $url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
77  }
78  }
79 
85  protected function boot($proceedIfNoUserIsLoggedIn)
86  {
87  $this->bootstrap
88  ->checkLockedBackendAndRedirectOrDie()
89  ->checkBackendIpOrDie()
90  ->checkSslBackendAndRedirectIfNeeded()
91  ->initializeBackendRouter()
92  ->loadBaseTca()
93  ->loadExtTables()
94  ->initializeBackendUser()
95  ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
96  ->initializeLanguageObject()
97  ->initializeBackendTemplate()
98  ->endOutputBufferingAndCleanPreviousOutput()
99  ->initializeOutputCompression()
100  ->sendHttpHeaders();
101  }
102 
109  public function canHandleRequest(ServerRequestInterface $request)
110  {
111  return TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI);
112  }
113 
120  public function getPriority()
121  {
122  return 50;
123  }
124 
133  protected function dispatch($request)
134  {
136  $response = GeneralUtility::makeInstance(Response::class);
138  $dispatcher = GeneralUtility::makeInstance(RouteDispatcher::class);
139  return $dispatcher->dispatch($request, $response);
140  }
141 }
canHandleRequest(ServerRequestInterface $request)
handleRequest(ServerRequestInterface $request)
static makeInstance($className,... $constructorArguments)
boot($proceedIfNoUserIsLoggedIn)
static redirect($url, $httpStatus=self::HTTP_STATUS_303)