Skip to content

Commit 37a92df

Browse files
committed
[ticket/16944] Add tests for iconify bundler
PHPBB3-16944
1 parent 42d8362 commit 37a92df

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

assets/iconify_bundler.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,26 @@ public function run()
4747
$organized_icons = $this->organize_icons_list();
4848

4949
$output = $this->load_icons_data($organized_icons);
50+
if (!$output)
51+
{
52+
return '';
53+
}
5054

5155
$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 . '
6670
})();' . "\n";
6771

6872
return $output;
@@ -111,7 +115,7 @@ protected function organize_icons_list(): array
111115
{
112116
// Split icon to prefix and name
113117
$icon = $this->name_to_icon($icon_name);
114-
if ($icon === null || $icon['provider'] !== '')
118+
if ($icon === null)
115119
{
116120
// Invalid name or icon name does not have provider
117121
if ($this->log)
@@ -216,24 +220,20 @@ protected function load_icons_data(array $icons): string
216220
{
217221
// Load icon set
218222
$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))
220225
{
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]);
225227
continue;
226228
}
227229

228230
// Make sure all icons exist
229-
foreach ($iconsList as $name)
231+
foreach ($iconsList as $key => $name)
230232
{
231233
if (!$collection->iconExists($name))
232234
{
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]);
237237
}
238238
}
239239

0 commit comments

Comments
 (0)