[TASK] Introduce unified RequestHandling for all requests
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / RequestHandler.php
1 <?php
2 namespace TYPO3\CMS\Backend;
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 TYPO3\CMS\Core\Core\Bootstrap;
18 use TYPO3\CMS\Core\Core\RequestHandlerInterface;
19
20 /**
21 * General RequestHandler for the TYPO3 Backend. This is used for all Backend requests except for CLI
22 * or AJAX calls. Unlike all other RequestHandlers in the TYPO3 CMS Core, the actual logic for choosing
23 * the controller is still done inside places like mod.php and each single file.
24 * This RequestHandler here serves solely to check and set up all requirements needed for a TYPO3 Backend.
25 * This class might be changed in the future.
26 */
27 class RequestHandler implements RequestHandlerInterface {
28
29 /**
30 * Instance of the current TYPO3 bootstrap
31 * @var Bootstrap
32 */
33 protected $bootstrap;
34
35 /**
36 * Constructor handing over the bootstrap
37 *
38 * @param Bootstrap $bootstrap
39 */
40 public function __construct(Bootstrap $bootstrap) {
41 $this->bootstrap = $bootstrap;
42 }
43
44 /**
45 * Handles any backend request
46 *
47 * @return void
48 */
49 public function handleRequest() {
50 $this->bootstrap
51 ->checkLockedBackendAndRedirectOrDie()
52 ->checkBackendIpOrDie()
53 ->checkSslBackendAndRedirectIfNeeded()
54 ->checkValidBrowserOrDie()
55 ->loadExtensionTables(TRUE)
56 ->initializeSpriteManager()
57 ->initializeBackendUser()
58 ->initializeBackendAuthentication()
59 ->initializeLanguageObject()
60 ->initializeBackendTemplate()
61 ->endOutputBufferingAndCleanPreviousOutput()
62 ->initializeOutputCompression()
63 ->sendHttpHeaders();
64 }
65
66 /**
67 * This request handler can handle any backend request (but not CLI).
68 *
69 * @return bool If the request is not a CLI script, TRUE otherwise FALSE
70 */
71 public function canHandleRequest() {
72 return (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI));
73 }
74
75 /**
76 * Returns the priority - how eager the handler is to actually handle the
77 * request.
78 *
79 * @return int The priority of the request handler.
80 */
81 public function getPriority() {
82 return 50;
83 }
84 }