[TASK] Replace sprite icon "actions-system-cache-clear-impact-*"
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Imaging / IconRegistry.php
1 <?php
2 namespace TYPO3\CMS\Core\Imaging;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
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.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Exception;
18 use TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider;
19 use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
20
21 /**
22 * Class IconRegistry, which makes it possible to register custom icons
23 * from within an extension.
24 */
25 class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
26
27 /**
28 * Registered icons
29 *
30 * @var array
31 */
32 protected $icons = array(
33 // Default icon, fallback
34 'default-not-found' => array(
35 'provider' => FontawesomeIconProvider::class,
36 'options' => array(
37 'name' => 'times-circle',
38 )
39 ),
40
41 // Action icons
42 'actions-document-close' => array(
43 'provider' => FontawesomeIconProvider::class,
44 'options' => array(
45 'name' => 'close',
46 )
47 ),
48 'actions-document-edit-access' => array(
49 'provider' => FontawesomeIconProvider::class,
50 'options' => array(
51 'name' => 'clock-o',
52 )
53 ),
54 'actions-document-export-t3d' => array(
55 'provider' => FontawesomeIconProvider::class,
56 'options' => array(
57 'name' => 'download',
58 )
59 ),
60 'actions-document-history-open' => array(
61 'provider' => FontawesomeIconProvider::class,
62 'options' => array(
63 'name' => 'history',
64 )
65 ),
66 'actions-document-info' => array(
67 'provider' => FontawesomeIconProvider::class,
68 'options' => array(
69 'name' => 'info-circle',
70 )
71 ),
72 'actions-document-import-t3d' => array(
73 'provider' => FontawesomeIconProvider::class,
74 'options' => array(
75 'name' => 'upload',
76 )
77 ),
78 'actions-document-move' => array(
79 'provider' => FontawesomeIconProvider::class,
80 'options' => array(
81 'name' => 'arrows',
82 )
83 ),
84 'actions-document-new' => array(
85 'provider' => FontawesomeIconProvider::class,
86 'options' => array(
87 'name' => 'plus-square',
88 )
89 ),
90 'actions-document-open' => array(
91 'provider' => FontawesomeIconProvider::class,
92 'options' => array(
93 'name' => 'pencil',
94 )
95 ),
96 'actions-document-paste-after' => array(
97 'provider' => FontawesomeIconProvider::class,
98 'options' => array(
99 'name' => 'clipboard',
100 )
101 ),
102 'actions-document-select' => array(
103 'provider' => FontawesomeIconProvider::class,
104 'options' => array(
105 'name' => 'check-square-o',
106 )
107 ),
108 'actions-document-paste-into' => array(
109 'provider' => FontawesomeIconProvider::class,
110 'options' => array(
111 'name' => 'clipboard',
112 )
113 ),
114 'actions-document-view' => array(
115 'provider' => FontawesomeIconProvider::class,
116 'options' => array(
117 'name' => 'desktop',
118 )
119 ),
120 'actions-edit-copy' => array(
121 'provider' => FontawesomeIconProvider::class,
122 'options' => array(
123 'name' => 'copy',
124 )
125 ),
126 'actions-edit-copy-release' => array(
127 'provider' => FontawesomeIconProvider::class,
128 'options' => array(
129 'name' => 'copy',
130 'additionalClasses' => 'text-danger',
131 )
132 ),
133 'actions-edit-cut' => array(
134 'provider' => FontawesomeIconProvider::class,
135 'options' => array(
136 'name' => 'scissors',
137 )
138 ),
139 'actions-edit-cut-release' => array(
140 'provider' => FontawesomeIconProvider::class,
141 'options' => array(
142 'name' => 'scissors',
143 'additionalClasses' => 'text-danger',
144 )
145 ),
146 'actions-edit-download' => array(
147 'provider' => FontawesomeIconProvider::class,
148 'options' => array(
149 'name' => 'download',
150 )
151 ),
152 'actions-edit-delete' => array(
153 'provider' => FontawesomeIconProvider::class,
154 'options' => array(
155 'name' => 'trash',
156 )
157 ),
158 'actions-edit-pick-date' => array(
159 'provider' => FontawesomeIconProvider::class,
160 'options' => array(
161 'name' => 'calendar',
162 )
163 ),
164 'actions-edit-rename' => array(
165 'provider' => FontawesomeIconProvider::class,
166 'options' => array(
167 'name' => 'quote-right',
168 )
169 ),
170 'actions-edit-replace' => array(
171 'provider' => FontawesomeIconProvider::class,
172 'options' => array(
173 'name' => 'retweet',
174 )
175 ),
176 'actions-edit-undo' => array(
177 'provider' => FontawesomeIconProvider::class,
178 'options' => array(
179 'name' => 'undo',
180 )
181 ),
182 'actions-edit-upload' => array(
183 'provider' => FontawesomeIconProvider::class,
184 'options' => array(
185 'name' => 'upload',
186 )
187 ),
188 'actions-markstate' => array(
189 'provider' => FontawesomeIconProvider::class,
190 'options' => array(
191 'name' => 'square-o',
192 )
193 ),
194 'actions-page-open' => array(
195 'provider' => FontawesomeIconProvider::class,
196 'options' => array(
197 'name' => 'pencil-square-o',
198 )
199 ),
200 'actions-system-cache-clear-impact-low' => array(
201 'provider' => SvgIconProvider::class,
202 'options' => array(
203 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-low.svg',
204 )
205 ),
206 'actions-system-cache-clear-impact-medium' => array(
207 'provider' => SvgIconProvider::class,
208 'options' => array(
209 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-medium.svg',
210 )
211 ),
212 'actions-system-cache-clear-impact-high' => array(
213 'provider' => SvgIconProvider::class,
214 'options' => array(
215 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-high.svg',
216 )
217 ),
218 'actions-system-list-open' => array(
219 'provider' => FontawesomeIconProvider::class,
220 'options' => array(
221 'name' => 'list-alt',
222 )
223 ),
224 'actions-version-open' => array(
225 'provider' => FontawesomeIconProvider::class,
226 'options' => array(
227 'name' => 'refresh',
228 )
229 ),
230 'actions-version-swap-version' => array(
231 'provider' => FontawesomeIconProvider::class,
232 'options' => array(
233 'name' => 'exchange',
234 )
235 ),
236 'actions-unmarkstate' => array(
237 'provider' => FontawesomeIconProvider::class,
238 'options' => array(
239 'name' => 'check-square-o',
240 )
241 ),
242
243 // Status
244 'status-status-current' => array(
245 'provider' => FontawesomeIconProvider::class,
246 'options' => array(
247 'name' => 'caret-right',
248 'additionalClasses' => 'text-danger',
249 )
250 ),
251
252 // Overlays
253 'overlay-read-only' => array(
254 'provider' => FontawesomeIconProvider::class,
255 'options' => array(
256 'name' => 'minus-circle',
257 )
258 ),
259 );
260
261 /**
262 * @var string
263 */
264 protected $defaultIconIdentifier = 'default-not-found';
265
266 /**
267 * @param string $identifier
268 *
269 * @return bool
270 */
271 public function isRegistered($identifier) {
272 return !empty($this->icons[$identifier]);
273 }
274
275 /**
276 * @return string
277 */
278 public function getDefaultIconIdentifier() {
279 return $this->defaultIconIdentifier;
280 }
281
282 /**
283 * Registers an icon to be available inside the Icon Factory
284 *
285 * @param string $identifier
286 * @param string $iconProviderClassName
287 * @param array $options
288 *
289 * @throws \InvalidArgumentException
290 */
291 public function registerIcon($identifier, $iconProviderClassName, array $options = array()) {
292 if (!in_array(IconProviderInterface::class, class_implements($iconProviderClassName), TRUE)) {
293 throw new \InvalidArgumentException('An IconProvider must implement ' . IconProviderInterface::class, 1437425803);
294 }
295 $this->icons[$identifier] = array(
296 'provider' => $iconProviderClassName,
297 'options' => $options
298 );
299 }
300
301 /**
302 * Fetches the configuration provided by registerIcon()
303 *
304 * @param string $identifier the icon identifier
305 * @return mixed
306 * @throws Exception
307 */
308 public function getIconConfigurationByIdentifier($identifier) {
309 if (!$this->isRegistered($identifier)) {
310 throw new Exception('Icon with identifier "' . $identifier . '" is not registered"', 1437425804);
311 }
312 return $this->icons[$identifier];
313 }
314
315 /**
316 * @return array
317 * @internal
318 */
319 public function getAllRegisteredIconIdentifiers() {
320 return array_keys($this->icons);
321 }
322 }