[FEATURE] Add SQL Logging to AdminPanel
[Packages/TYPO3.CMS.git] / typo3 / sysext / adminpanel / Classes / Hooks / RenderHook.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Adminpanel\Hooks;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\CMS\Adminpanel\Controller\MainController;
20 use TYPO3\CMS\Adminpanel\Utility\StateUtility;
21 use TYPO3\CMS\Core\Utility\GeneralUtility;
22 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
23
24 /**
25 * Hook to render the admin panel
26 *
27 * @internal
28 */
29 class RenderHook
30 {
31 /**
32 * Hook to render the admin panel
33 * We use a hook this late in the project to make sure all data is collected and can be displayed
34 * As the main content is already rendered, we use a string replace on the content to append the adminPanel
35 * to the HTML body.
36 *
37 * @param array $params
38 * @param TypoScriptFrontendController $pObj
39 */
40 public function renderAdminPanel(array $params, TypoScriptFrontendController $pObj): void
41 {
42 if (
43 StateUtility::isActivated() &&
44 !$GLOBALS['BE_USER']->extAdminConfig['hide'] && $pObj->config['config']['admPanel']
45 ) {
46 $mainController = GeneralUtility::makeInstance(MainController::class);
47
48 $pObj->content = str_ireplace(
49 '</body>',
50 $mainController->render() . '</body>',
51 $pObj->content
52 );
53 }
54 }
55 }