‪TYPO3CMS  ‪main
SvgSpriteIconProvider.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 
23 
30 {
34  protected function ‪generateMarkup(‪Icon $icon, array $options): string
35  {
36  if (empty($options['sprite'])) {
37  throw new \InvalidArgumentException('[' . $icon->‪getIdentifier() . '] The option "source" is required and must not be empty', 1603439142);
38  }
39 
40  $source = $options['sprite'];
41  return '<svg class="icon-color"><use xlink:href="' . htmlspecialchars($this->‪getPublicPath($source)) . '" /></svg>';
42  }
43 
47  protected function ‪generateInlineMarkup(array $options): string
48  {
49  if (empty($options['source'])) {
50  throw new \InvalidArgumentException('The option "source" is required and must not be empty', 1603439146);
51  }
52 
53  $source = $options['source'];
54 
56  $source = GeneralUtility::getFileAbsFileName($source);
57  }
58 
59  return $this->‪getInlineSvg($source);
60  }
61 }
‪TYPO3\CMS\Core\Utility\PathUtility\isExtensionPath
‪static isExtensionPath(string $path)
Definition: PathUtility.php:117
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Core\Utility\PathUtility\isAbsolutePath
‪static isAbsolutePath(string $path)
Definition: PathUtility.php:286
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:27
‪TYPO3\CMS\Core\Imaging\IconProvider\AbstractSvgIconProvider\getInlineSvg
‪getInlineSvg(string $source)
Definition: AbstractSvgIconProvider.php:55
‪TYPO3\CMS\Core\Imaging\IconProvider\AbstractSvgIconProvider
Definition: AbstractSvgIconProvider.php:31
‪TYPO3\CMS\Core\Imaging\IconProvider
Definition: AbstractSvgIconProvider.php:18
‪TYPO3\CMS\Core\Imaging\IconProvider\SvgSpriteIconProvider
Definition: SvgSpriteIconProvider.php:30
‪TYPO3\CMS\Core\Imaging\Icon\getIdentifier
‪getIdentifier()
Definition: Icon.php:141
‪TYPO3\CMS\Core\Imaging\IconProvider\SvgSpriteIconProvider\generateMarkup
‪generateMarkup(Icon $icon, array $options)
Definition: SvgSpriteIconProvider.php:34
‪TYPO3\CMS\Core\Imaging\IconProvider\AbstractSvgIconProvider\getPublicPath
‪getPublicPath(string $source)
Definition: AbstractSvgIconProvider.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Imaging\IconProvider\SvgSpriteIconProvider\generateInlineMarkup
‪generateInlineMarkup(array $options)
Definition: SvgSpriteIconProvider.php:47