@@ -47,22 +47,26 @@ public function run()
47
47
$ organized_icons = $ this ->organize_icons_list ();
48
48
49
49
$ output = $ this ->load_icons_data ($ organized_icons );
50
+ if (!$ output )
51
+ {
52
+ return '' ;
53
+ }
50
54
51
55
$ output = '(function() {
52
- function add(data) {
53
- try {
54
- if (typeof self.Iconify === \'object \' && self.Iconify.addCollection) {
55
- self.Iconify.addCollection(data);
56
- return;
57
- }
58
- if (typeof self.IconifyPreload === \'undefined \') {
59
- self.IconifyPreload = [];
60
- }
61
- self.IconifyPreload.push(data);
62
- } catch (err) {
63
- }
64
- }
65
- ' . $ output . '
56
+ function add(data) {
57
+ try {
58
+ if (typeof self.Iconify === \'object \' && self.Iconify.addCollection) {
59
+ self.Iconify.addCollection(data);
60
+ return;
61
+ }
62
+ if (typeof self.IconifyPreload === \'undefined \') {
63
+ self.IconifyPreload = [];
64
+ }
65
+ self.IconifyPreload.push(data);
66
+ } catch (err) {
67
+ }
68
+ }
69
+ ' . $ output . '
66
70
})(); ' . "\n" ;
67
71
68
72
return $ output ;
@@ -111,7 +115,7 @@ protected function organize_icons_list(): array
111
115
{
112
116
// Split icon to prefix and name
113
117
$ icon = $ this ->name_to_icon ($ icon_name );
114
- if ($ icon === null || $ icon [ ' provider ' ] !== '' )
118
+ if ($ icon === null )
115
119
{
116
120
// Invalid name or icon name does not have provider
117
121
if ($ this ->log )
@@ -216,24 +220,20 @@ protected function load_icons_data(array $icons): string
216
220
{
217
221
// Load icon set
218
222
$ collection = new Collection ($ prefix );
219
- if (!$ collection ->loadIconifyCollection ($ prefix ))
223
+ $ collection_file = Collection::findIconifyCollection ($ prefix );
224
+ if (!file_exists ($ collection_file ) || !$ collection ->loadFromFile ($ collection_file ))
220
225
{
221
- if ($ this ->log )
222
- {
223
- $ this ->log ->add ('critical ' , ANONYMOUS , '' , 'LOG_ICON_COLLECTION_INVALID ' , false , [$ prefix ]);
224
- }
226
+ $ this ->log ?->add('critical ' , ANONYMOUS , '' , 'LOG_ICON_COLLECTION_INVALID ' , false , [$ prefix ]);
225
227
continue ;
226
228
}
227
229
228
230
// Make sure all icons exist
229
- foreach ($ iconsList as $ name )
231
+ foreach ($ iconsList as $ key => $ name )
230
232
{
231
233
if (!$ collection ->iconExists ($ name ))
232
234
{
233
- if ($ this ->log )
234
- {
235
- $ this ->log ->add ('critical ' , ANONYMOUS , '' , 'LOG_ICON_INVALID ' , false , [$ prefix . ': ' . $ name ]);
236
- }
235
+ $ this ->log ?->add('critical ' , ANONYMOUS , '' , 'LOG_ICON_INVALID ' , false , [$ prefix . ': ' . $ name ]);
236
+ unset($ iconsList [$ key ]);
237
237
}
238
238
}
239
239
0 commit comments