Skip to content

Commit 1356e25

Browse files
committed
Remove code duplication.
1 parent ae3e6cc commit 1356e25

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

src/Command/AssetsCommand.php

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -228,46 +228,33 @@ private function createStore(): void
228228
*/
229229
private function findAssets(): void
230230
{
231+
// Assets supplied by packages.
231232
$plaisioXmlList = PlaisioXmlUtility::findPlaisioXmlPackages('assets');
233+
$collections = [];
232234
foreach ($plaisioXmlList as $plaisioConfigPath)
233235
{
234236
$helper = new AssetsPlaisioXmlHelper($plaisioConfigPath);
235-
$collections = $helper->queryAssetFileList();
236-
if (!empty($collections))
237-
{
238-
foreach ($collections as $collection)
239-
{
240-
foreach ($collection['files'] as $file)
241-
{
242-
$this->io->logVerbose('Found asset <fso>%s</fso>', Path::join($collection['base-dir'], $file));
243-
244-
$this->store->insertRow('PLS_ASSET', ['ass_id' => null,
245-
'ass_type' => $collection['type'],
246-
'ass_base_dir' => $collection['base-dir'],
247-
'ass_to_dir' => $collection['to-dir'],
248-
'ass_path' => $file]);
249-
}
250-
}
251-
}
237+
$tmp = $helper->queryAssetFileList();
238+
$collections = array_merge($collections, $tmp);
252239
}
253240

241+
// Third party assets.
254242
$plaisioConfigPath = PlaisioXmlUtility::plaisioXmlPath('assets');
255243
$helper = new AssetsPlaisioXmlHelper($plaisioConfigPath);
256-
$collections = $helper->queryOtherAssetFileList();
257-
if (!empty($collections))
244+
$tmp = $helper->queryOtherAssetFileList();
245+
$collections = array_merge($collections, $tmp);
246+
247+
foreach ($collections as $collection)
258248
{
259-
foreach ($collections as $collection)
249+
foreach ($collection['files'] as $file)
260250
{
261-
foreach ($collection['files'] as $file)
262-
{
263-
$this->io->logVerbose('Found asset <fso>%s</fso>', Path::join($collection['base-dir'], $file));
264-
265-
$this->store->insertRow('PLS_ASSET', ['ass_id' => null,
266-
'ass_type' => $collection['type'],
267-
'ass_base_dir' => $collection['base-dir'],
268-
'ass_to_dir' => $collection['to-dir'],
269-
'ass_path' => $file]);
270-
}
251+
$this->io->logVerbose('Found asset <fso>%s</fso>', Path::join($collection['base-dir'], $file));
252+
253+
$this->store->insertRow('PLS_ASSET', ['ass_id' => null,
254+
'ass_type' => $collection['type'],
255+
'ass_base_dir' => $collection['base-dir'],
256+
'ass_to_dir' => $collection['to-dir'],
257+
'ass_path' => $file]);
271258
}
272259
}
273260
}

0 commit comments

Comments
 (0)