‪TYPO3CMS  ‪main
SvgIconProvider.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 
26 {
30  protected function ‪generateMarkup(‪Icon $icon, array $options): string
31  {
32  if (empty($options['source'])) {
33  throw new \InvalidArgumentException('[' . $icon->‪getIdentifier() . '] The option "source" is required and must not be empty', 1460976566);
34  }
35 
36  $source = $options['source'];
37  return '<img src="' . htmlspecialchars($this->‪getPublicPath($source)) . '" width="' . $icon->‪getDimension()->getWidth() . '" height="' . $icon->‪getDimension()->getHeight() . '" alt="" />';
38  }
39 
43  protected function ‪generateInlineMarkup(array $options): string
44  {
45  if (empty($options['source'])) {
46  throw new \InvalidArgumentException('The option "source" is required and must not be empty', 1460976610);
47  }
48 
49  $source = $options['source'];
50 
52  $source = GeneralUtility::getFileAbsFileName($source);
53  }
54 
55  return $this->‪getInlineSvg($source);
56  }
57 }
‪TYPO3\CMS\Core\Utility\PathUtility\isExtensionPath
‪static isExtensionPath(string $path)
Definition: PathUtility.php:118
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Core\Utility\PathUtility\isAbsolutePath
‪static isAbsolutePath(string $path)
Definition: PathUtility.php:287
‪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\SvgIconProvider\generateInlineMarkup
‪generateInlineMarkup(array $options)
Definition: SvgIconProvider.php:43
‪TYPO3\CMS\Core\Imaging\Icon\getIdentifier
‪getIdentifier()
Definition: Icon.php:141
‪TYPO3\CMS\Core\Imaging\IconProvider\AbstractSvgIconProvider\getPublicPath
‪getPublicPath(string $source)
Definition: AbstractSvgIconProvider.php:46
‪TYPO3\CMS\Core\Imaging\Icon\getDimension
‪getDimension()
Definition: Icon.php:232
‪TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider
Definition: SvgIconProvider.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider\generateMarkup
‪generateMarkup(Icon $icon, array $options)
Definition: SvgIconProvider.php:30