‪TYPO3CMS  9.5
AdminPanelRenderer.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
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 Psr\Http\Message\ResponseInterface;
20 use Psr\Http\Message\ServerRequestInterface;
21 use Psr\Http\Server\MiddlewareInterface;
22 use Psr\Http\Server\RequestHandlerInterface;
29 
35 class ‪AdminPanelRenderer implements MiddlewareInterface
36 {
37 
44  public function ‪process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
45  {
46  $response = $handler->handle($request);
47  if (
48  !($response instanceof ‪NullResponse)
49  && ‪$GLOBALS['TSFE'] instanceof ‪TypoScriptFrontendController
50  && ‪$GLOBALS['TSFE']->isOutputting()
54  ) {
55  $mainController = GeneralUtility::makeInstance(MainController::class);
56  $body = $response->getBody();
57  $body->rewind();
58  $contents = $response->getBody()->getContents();
59  $content = str_ireplace(
60  '</body>',
61  $mainController->render($request) . '</body>',
62  $contents
63  );
64  $body = new ‪Stream('php://temp', 'rw');
65  $body->write($content);
66  $response = $response->withBody($body);
67  }
68  return $response;
69  }
70 }
‪TYPO3\CMS\Adminpanel\Controller\MainController
Definition: MainController.php:45
‪TYPO3\CMS\Adminpanel\Middleware
Definition: AdminPanelDataPersister.php:4
‪TYPO3\CMS\Adminpanel\Utility\StateUtility\isActivatedForUser
‪static bool isActivatedForUser()
Definition: StateUtility.php:33
‪TYPO3\CMS\Adminpanel\Utility\StateUtility\isHiddenForUser
‪static isHiddenForUser()
Definition: StateUtility.php:65
‪TYPO3\CMS\Core\Http\NullResponse
Definition: NullResponse.php:24
‪TYPO3\CMS\Adminpanel\Utility\StateUtility
Definition: StateUtility.php:27
‪TYPO3\CMS\Adminpanel\Middleware\AdminPanelRenderer\process
‪ResponseInterface process(ServerRequestInterface $request, RequestHandlerInterface $handler)
Definition: AdminPanelRenderer.php:44
‪TYPO3\CMS\Adminpanel\Middleware\AdminPanelRenderer
Definition: AdminPanelRenderer.php:36
‪TYPO3\CMS\Core\Http\Stream
Definition: Stream.php:28
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:97
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Adminpanel\Utility\StateUtility\isActivatedInTypoScript
‪static isActivatedInTypoScript()
Definition: StateUtility.php:60