bf4ed837cbd0d01ee8ca8148c525083cf23ffe21
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Http / RequestHandler.php
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
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 // Evaluate the constant for skipping the BE user check for the bootstrap
51 if (defined('TYPO3_PROCEED_IF_NO_USER') && TYPO3_PROCEED_IF_NO_USER) {
52 $proceedIfNoUserIsLoggedIn = TRUE;
53 } else {
54 $proceedIfNoUserIsLoggedIn = FALSE;
55 }
56
57 $this->bootstrap
58 ->checkLockedBackendAndRedirectOrDie()
59 ->checkBackendIpOrDie()
60 ->checkSslBackendAndRedirectIfNeeded()
61 ->checkValidBrowserOrDie()
62 ->loadExtensionTables(TRUE)
63 ->initializeSpriteManager()
64 ->initializeBackendUser()
65 ->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)
66 ->initializeLanguageObject()
67 ->initializeBackendTemplate()
68 ->endOutputBufferingAndCleanPreviousOutput()
69 ->initializeOutputCompression()
70 ->sendHttpHeaders();
71 }
72
73 /**
74 * This request handler can handle any backend request (but not CLI).
75 *
76 * @return bool If the request is not a CLI script, TRUE otherwise FALSE
77 */
78 public function canHandleRequest() {
79 return (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI));
80 }
81
82 /**
83 * Returns the priority - how eager the handler is to actually handle the
84 * request.
85 *
86 * @return int The priority of the request handler.
87 */
88 public function getPriority() {
89 return 50;
90 }
91 }