‪TYPO3CMS  ‪main
AdminPanelRenderer.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Container\ContainerInterface;
21 use Psr\Http\Message\ResponseInterface;
22 use Psr\Http\Message\ServerRequestInterface;
23 use Psr\Http\Server\MiddlewareInterface;
24 use Psr\Http\Server\RequestHandlerInterface;
28 
34 readonly class ‪AdminPanelRenderer implements MiddlewareInterface
35 {
36  public function ‪__construct(
37  private ContainerInterface $container,
38  ) {}
39 
43  public function ‪process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
44  {
45  $response = $handler->handle($request);
46  $typoScriptConfig = $request->getAttribute('frontend.typoscript')->getConfigArray();
48  && ($typoScriptConfig['admPanel'] ?? false)
50  ) {
51  $body = $response->getBody();
52  $body->rewind();
53  $contents = $response->getBody()->getContents();
54  $content = str_ireplace(
55  '</body>',
56  $this->container->get(MainController::class)->render($request) . '</body>',
57  $contents
58  );
59  $body = new ‪Stream('php://temp', 'rw');
60  $body->write($content);
61  $response = $response->withBody($body);
62  }
63  return $response;
64  }
65 }
‪TYPO3\CMS\Adminpanel\Controller\MainController
Definition: MainController.php:49
‪TYPO3\CMS\Adminpanel\Middleware
Definition: AdminPanelDataPersister.php:18
‪TYPO3\CMS\Adminpanel\Utility\StateUtility\isHiddenForUser
‪static isHiddenForUser()
Definition: StateUtility.php:55
‪TYPO3\CMS\Adminpanel\Utility\StateUtility
Definition: StateUtility.php:28
‪TYPO3\CMS\Adminpanel\Utility\StateUtility\isActivatedForUser
‪static isActivatedForUser()
Definition: StateUtility.php:32
‪TYPO3\CMS\Adminpanel\Middleware\AdminPanelRenderer
Definition: AdminPanelRenderer.php:35
‪TYPO3\CMS\Core\Http\Stream
Definition: Stream.php:31
‪TYPO3\CMS\Adminpanel\Middleware\AdminPanelRenderer\process
‪process(ServerRequestInterface $request, RequestHandlerInterface $handler)
Definition: AdminPanelRenderer.php:43
‪TYPO3\CMS\Adminpanel\Middleware\AdminPanelRenderer\__construct
‪__construct(private ContainerInterface $container,)
Definition: AdminPanelRenderer.php:36