2 namespace TYPO3\CMS\Core\Imaging
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Core\Exception
;
18 use TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider
;
21 * Class IconRegistry, which makes it possible to register custom icons
22 * from within an extension.
24 class IconRegistry
implements \TYPO3\CMS\Core\SingletonInterface
{
31 protected $icons = array(
32 // Default icon, fallback
33 'default-not-found' => array(
34 'provider' => FontawesomeIconProvider
::class,
36 'name' => 'times-circle',
41 'actions-document-close' => array(
42 'provider' => FontawesomeIconProvider
::class,
47 'actions-document-edit-access' => array(
48 'provider' => FontawesomeIconProvider
::class,
53 'actions-document-export-t3d' => array(
54 'provider' => FontawesomeIconProvider
::class,
59 'actions-document-history-open' => array(
60 'provider' => FontawesomeIconProvider
::class,
65 'actions-document-info' => array(
66 'provider' => FontawesomeIconProvider
::class,
68 'name' => 'info-circle',
71 'actions-document-import-t3d' => array(
72 'provider' => FontawesomeIconProvider
::class,
77 'actions-document-move' => array(
78 'provider' => FontawesomeIconProvider
::class,
84 'actions-document-new' => array(
85 'provider' => FontawesomeIconProvider
::class,
87 'name' => 'plus-square',
90 'actions-document-open' => array(
91 'provider' => FontawesomeIconProvider
::class,
96 'actions-document-paste-after' => array(
97 'provider' => FontawesomeIconProvider
::class,
99 'name' => 'clipboard',
102 'actions-document-view' => array(
103 'provider' => FontawesomeIconProvider
::class,
108 'actions-edit-copy' => array(
109 'provider' => FontawesomeIconProvider
::class,
114 'actions-edit-copy-release' => array(
115 'provider' => FontawesomeIconProvider
::class,
117 'name' => 'copy text-danger',
120 'actions-edit-cut' => array(
121 'provider' => FontawesomeIconProvider
::class,
123 'name' => 'scissors',
126 'actions-edit-cut-release' => array(
127 'provider' => FontawesomeIconProvider
::class,
129 'name' => 'scissors text-danger',
134 'overlay-read-only' => array(
135 'provider' => FontawesomeIconProvider
::class,
137 'name' => 'minus-circle',
145 protected $defaultIconIdentifier = 'default-not-found';
152 public function isRegistered($identifier) {
153 return !empty($this->icons
[$identifier]);
159 public function getDefaultIconIdentifier() {
160 return $this->defaultIconIdentifier
;
164 * Registers an icon to be available inside the Icon Factory
166 * @param string $identifier
167 * @param string $iconProviderClassName
168 * @param array $options
170 * @throws \InvalidArgumentException
172 public function registerIcon($identifier, $iconProviderClassName, array $options = array()) {
173 if (!in_array(IconProviderInterface
::class, class_implements($iconProviderClassName), TRUE)) {
174 throw new \
InvalidArgumentException('An IconProvider must implement ' . IconProviderInterface
::class, 1437425803);
176 $this->icons
[$identifier] = array(
177 'provider' => $iconProviderClassName,
178 'options' => $options
183 * Fetches the configuration provided by registerIcon()
185 * @param string $identifier the icon identifier
189 public function getIconConfigurationByIdentifier($identifier) {
190 if (!$this->isRegistered($identifier)) {
191 throw new Exception('Icon with identifier "' . $identifier . '" is not registered"', 1437425804);
193 return $this->icons
[$identifier];