‪TYPO3CMS  10.4
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 {
36  protected ‪$iconRegistry;
37 
41  protected ‪$iconFactory;
42 
44  {
45  $this->iconRegistry = ‪$iconRegistry;
46  $this->iconFactory = ‪$iconFactory;
47  }
48 
53  public function ‪getCacheIdentifierAction(): ResponseInterface
54  {
55  return new ‪HtmlResponse($this->iconRegistry->getCacheIdentifier());
56  }
57 
63  public function ‪getIconAction(ServerRequestInterface $request): ResponseInterface
64  {
65  $parsedBody = $request->getParsedBody();
66  $queryParams = $request->getQueryParams();
67  $requestedIcon = json_decode($parsedBody['icon'] ?? $queryParams['icon'], true);
68 
69  [$identifier, $size, $overlayIdentifier, $iconState, $alternativeMarkupIdentifier] = $requestedIcon;
70 
71  if (empty($overlayIdentifier)) {
72  $overlayIdentifier = null;
73  }
74 
75  $iconState = ‪IconState::cast($iconState);
76  $icon = $this->iconFactory->getIcon($identifier, $size, $overlayIdentifier, $iconState);
77 
78  return new HtmlResponse($icon->render($alternativeMarkupIdentifier));
79  }
80 }
‪TYPO3\CMS\Install\Controller\IconController\getIconAction
‪ResponseInterface getIconAction(ServerRequestInterface $request)
Definition: IconController.php:61
‪TYPO3\CMS\Install\Controller\IconController\$iconRegistry
‪IconRegistry $iconRegistry
Definition: IconController.php:35
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Install\Controller\IconController
Definition: IconController.php:32
‪TYPO3\CMS\Install\Controller\IconController\$iconFactory
‪IconFactory $iconFactory
Definition: IconController.php:39
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Install\Controller
Definition: AbstractController.php:18
‪TYPO3\CMS\Core\Imaging\IconRegistry
Definition: IconRegistry.php:38
‪TYPO3\CMS\Install\Controller\IconController\getCacheIdentifierAction
‪ResponseInterface getCacheIdentifierAction()
Definition: IconController.php:51
‪TYPO3\CMS\Core\Type\Icon\IconState
Definition: IconState.php:24
‪TYPO3\CMS\Install\Controller\AbstractController
Definition: AbstractController.php:31
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26
‪TYPO3\CMS\Install\Controller\IconController\__construct
‪__construct(IconRegistry $iconRegistry, IconFactory $iconFactory)
Definition: IconController.php:41