File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 14
14
use Symfony \UX \Icons \Command \WarmCacheCommand ;
15
15
use Symfony \UX \Icons \IconRenderer ;
16
16
use Symfony \UX \Icons \Registry \CacheIconRegistry ;
17
+ use Symfony \UX \Icons \Registry \ChainIconRegistry ;
17
18
use Symfony \UX \Icons \Registry \LocalSvgIconRegistry ;
18
19
use Symfony \UX \Icons \Twig \IconFinder ;
19
20
use Symfony \UX \Icons \Twig \UXIconComponent ;
24
25
$ container ->services ()
25
26
->set ('.ux_icons.cache_icon_registry ' , CacheIconRegistry::class)
26
27
->args ([
27
- service ('.ux_icons.local_svg_icon_registry ' ),
28
+ service ('.ux_icons.chain_registry ' ),
28
29
service ('cache.system ' ),
29
30
])
30
31
31
32
->set ('.ux_icons.local_svg_icon_registry ' , LocalSvgIconRegistry::class)
32
33
->args ([
33
34
abstract_arg ('icon_dir ' ),
34
35
])
36
+ ->tag ('ux_icons.registry ' , ['priority ' => 10 ])
37
+
38
+ ->set ('.ux_icons.chain_registry ' , ChainIconRegistry::class)
39
+ ->args ([
40
+ tagged_iterator ('ux_icons.registry ' ),
41
+ ])
35
42
36
43
->alias ('.ux_icons.icon_registry ' , '.ux_icons.cache_icon_registry ' )
37
44
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \UX \Icons \Registry ;
13
+
14
+ use Symfony \UX \Icons \Exception \IconNotFoundException ;
15
+ use Symfony \UX \Icons \IconRegistryInterface ;
16
+ use Symfony \UX \Icons \Svg \Icon ;
17
+
18
+ /**
19
+ * @author Kevin Bond <kevinbond@gmail.com>
20
+ *
21
+ * @internal
22
+ */
23
+ final class ChainIconRegistry implements IconRegistryInterface
24
+ {
25
+ /**
26
+ * @param IconRegistryInterface[] $registries
27
+ */
28
+ public function __construct (private iterable $ registries )
29
+ {
30
+ }
31
+
32
+ public function get (string $ name ): Icon
33
+ {
34
+ foreach ($ this ->registries as $ registry ) {
35
+ try {
36
+ return $ registry ->get ($ name );
37
+ } catch (IconNotFoundException ) {
38
+ }
39
+ }
40
+
41
+ throw new IconNotFoundException (sprintf ('Icon "%s" not found. ' , $ name ));
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments