mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-01-27 15:48:41 +00:00
Optimize navigation install
This commit is contained in:
parent
5e84da05ce
commit
9d014c1c67
|
|
@ -19,6 +19,7 @@ use phpOMS\DataStorage\Database\DatabaseType;
|
|||
use phpOMS\DataStorage\Database\RelationType;
|
||||
use phpOMS\Module\InfoManager;
|
||||
use phpOMS\Module\InstallerAbstract;
|
||||
use phpOMS\System\File\PathException;
|
||||
use Modules\Navigation\Models\NavElement;
|
||||
use Modules\Navigation\Models\NavElementMapper;
|
||||
|
||||
|
|
@ -41,6 +42,9 @@ class Installer extends InstallerAbstract
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws PathException This exception is thrown if the Navigation install file couldn't be found
|
||||
* @throws \Exception This exception is thrown if the Navigation install file is invalid json
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function installExternal(DatabasePool $dbPool, array $data) : void
|
||||
|
|
@ -51,7 +55,19 @@ class Installer extends InstallerAbstract
|
|||
return;
|
||||
}
|
||||
|
||||
foreach ($data as $link) {
|
||||
$navFile = \file_get_contents($data['path'] ?? '');
|
||||
|
||||
if ($navFile === false) {
|
||||
throw new PathException($data['path'] ?? '');
|
||||
}
|
||||
|
||||
$navData = \json_decode($navFile, true);
|
||||
|
||||
if ($navData === false) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
foreach ($navData as $link) {
|
||||
self::installLink($dbPool, $link);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user