‪TYPO3CMS  9.5
IconController.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
25 
31 {
35  protected ‪$iconRegistry;
36 
40  protected ‪$iconFactory;
41 
45  public function ‪__construct()
46  {
47  $this->iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
48  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
49  }
50 
55  public function ‪getCacheIdentifierAction(): ResponseInterface
56  {
57  return new ‪HtmlResponse($this->iconRegistry->getCacheIdentifier());
58  }
59 
65  public function ‪getIconAction(ServerRequestInterface $request): ResponseInterface
66  {
67  $parsedBody = $request->getParsedBody();
68  $queryParams = $request->getQueryParams();
69  $requestedIcon = json_decode($parsedBody['icon'] ?? $queryParams['icon'], true);
70 
71  list($identifier, $size, $overlayIdentifier, $iconState, $alternativeMarkupIdentifier) = $requestedIcon;
72 
73  if (empty($overlayIdentifier)) {
74  $overlayIdentifier = null;
75  }
76 
77  $iconState = ‪IconState::cast($iconState);
78  $icon = $this->iconFactory->getIcon($identifier, $size, $overlayIdentifier, $iconState);
79 
80  return new ‪HtmlResponse($icon->render($alternativeMarkupIdentifier));
81  }
82 }
‪TYPO3\CMS\Install\Controller\IconController\getIconAction
‪ResponseInterface getIconAction(ServerRequestInterface $request)
Definition: IconController.php:63
‪TYPO3\CMS\Install\Controller\IconController\__construct
‪__construct()
Definition: IconController.php:43
‪TYPO3\CMS\Install\Controller\IconController\$iconRegistry
‪IconRegistry $iconRegistry
Definition: IconController.php:34
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Install\Controller\IconController
Definition: IconController.php:31
‪TYPO3\CMS\Install\Controller\IconController\$iconFactory
‪IconFactory $iconFactory
Definition: IconController.php:38
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:182
‪TYPO3\CMS\Install\Controller
Definition: AbstractController.php:3
‪TYPO3\CMS\Core\Imaging\IconRegistry
Definition: IconRegistry.php:34
‪TYPO3\CMS\Install\Controller\IconController\getCacheIdentifierAction
‪ResponseInterface getCacheIdentifierAction()
Definition: IconController.php:53
‪TYPO3\CMS\Core\Type\Icon\IconState
Definition: IconState.php:23
‪TYPO3\CMS\Install\Controller\AbstractController
Definition: AbstractController.php:28
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:25