‪TYPO3CMS  ‪main
IconController.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\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
26 
32 {
33  public function ‪__construct(
34  protected readonly ‪IconRegistry $iconRegistry,
35  protected readonly ‪IconFactory $iconFactory
36  ) {}
37 
41  public function ‪getCacheIdentifierAction(): ResponseInterface
42  {
43  return new ‪HtmlResponse($this->iconRegistry->getBackendIconsCacheIdentifier());
44  }
45 
49  public function ‪getIconAction(ServerRequestInterface $request): ResponseInterface
50  {
51  $parsedBody = $request->getParsedBody();
52  $queryParams = $request->getQueryParams();
53  $requestedIcon = json_decode($parsedBody['icon'] ?? $queryParams['icon'], true);
54 
55  [‪$identifier, $size, $overlayIdentifier, $iconState, $alternativeMarkupIdentifier] = $requestedIcon;
56 
57  if (empty($overlayIdentifier)) {
58  $overlayIdentifier = null;
59  }
60 
61  $iconState = IconState::tryFrom($iconState);
62  $icon = $this->iconFactory->getIcon(‪$identifier, $size, $overlayIdentifier, $iconState);
63 
64  return new ‪HtmlResponse($icon->render($alternativeMarkupIdentifier));
65  }
66 }
‪TYPO3\CMS\Install\Controller\IconController\__construct
‪__construct(protected readonly IconRegistry $iconRegistry, protected readonly IconFactory $iconFactory)
Definition: IconController.php:33
‪TYPO3\CMS\Install\Controller\IconController\getCacheIdentifierAction
‪getCacheIdentifierAction()
Definition: IconController.php:41
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Install\Controller\IconController
Definition: IconController.php:32
‪TYPO3\CMS\Install\Controller
Definition: AbstractController.php:18
‪TYPO3\CMS\Core\Imaging\IconRegistry
Definition: IconRegistry.php:32
‪TYPO3\CMS\Install\Controller\IconController\getIconAction
‪getIconAction(ServerRequestInterface $request)
Definition: IconController.php:49
‪TYPO3\CMS\Core\Imaging\IconState
‪IconState
Definition: IconState.php:24
‪TYPO3\CMS\Install\Controller\AbstractController
Definition: AbstractController.php:35
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:28