TYPO3 CMS  TYPO3_8-7
Application.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  */
18 
23 {
27  protected $bootstrap;
28 
34  protected $entryPointLevel = 1;
35 
39  protected $request;
40 
46  \TYPO3\CMS\Backend\Http\RequestHandler::class,
47  \TYPO3\CMS\Backend\Http\BackendModuleRequestHandler::class,
48  \TYPO3\CMS\Backend\Http\AjaxRequestHandler::class
49  ];
50 
56  public function __construct($classLoader)
57  {
58  $this->defineLegacyConstants();
59 
60  $this->bootstrap = Bootstrap::getInstance()
61  ->initializeClassLoader($classLoader)
62  ->setRequestType(TYPO3_REQUESTTYPE_BE | (!empty($_GET['ajaxID']) ? TYPO3_REQUESTTYPE_AJAX : 0))
63  ->baseSetup($this->entryPointLevel);
64 
65  // Redirect to install tool if base configuration is not found
66  if (!$this->bootstrap->checkIfEssentialConfigurationExists()) {
67  $this->bootstrap->redirectToInstallTool($this->entryPointLevel);
68  }
69 
70  foreach ($this->availableRequestHandlers as $requestHandler) {
71  $this->bootstrap->registerRequestHandlerImplementation($requestHandler);
72  }
73 
74  $this->bootstrap->configure();
75  }
76 
82  public function run(callable $execute = null)
83  {
85  // see below when this option is set and Bootstrap::defineTypo3RequestTypes() for more details
86  if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
87  $this->request = $this->request->withAttribute('isAjaxRequest', true);
88  } elseif (isset($this->request->getQueryParams()['M'])) {
89  $this->request = $this->request->withAttribute('isModuleRequest', true);
90  }
91 
92  $this->bootstrap->handleRequest($this->request);
93 
94  if ($execute !== null) {
95  call_user_func($execute);
96  }
97 
98  $this->bootstrap->shutdown();
99  }
100 
104  protected function defineLegacyConstants()
105  {
106  define('TYPO3_MODE', 'BE');
107  }
108 }
run(callable $execute=null)
Definition: Application.php:82