diff --git a/Admin/Installer.php b/Admin/Installer.php index a78751f..f4cfd3f 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -20,6 +20,8 @@ use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Module\InstallerAbstract; use phpOMS\Module\ModuleInfo; +use phpOMS\Application\ApplicationAbstract; +use phpOMS\System\File\PathException; /** * Installer class. @@ -172,5 +174,51 @@ final class Installer extends InstallerAbstract */ public static function installExternal(ApplicationAbstract $app, array $data) : array { + if (!\is_file($data['path'] ?? '')) { + throw new PathException($data['path'] ?? ''); + } + + $adminFile = \file_get_contents($data['path'] ?? ''); + if ($adminFile === false) { + throw new PathException($data['path'] ?? ''); // @codeCoverageIgnore + } + + $adminData = \json_decode($adminFile, true) ?? []; + if ($adminData === false) { + throw new \Exception(); // @codeCoverageIgnore + } + + $result = [ + 'settings' => [], + ]; + + foreach ($adminData as $admin) { + switch ($admin['type']) { + case 'setting': + $result['settings'][] = self::createSettings($app, $admin); + break; + default: + } + } + + return $result; + } + + /** + * Create settings. + * + * @param ApplicationAbstract $app Database instance + * @param array $settings Media info + * + * @return array + * + * @since 1.0.0 + */ + private static function createSettings(ApplicationAbstract $app, array $setting) : array + { + unset($setting['type']); + $app->appSettings->create($setting); + + return $setting; } } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b9dc7a5..cab9f5e 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,14 +12,7 @@ If you have a good idea for improvement feel free to create a new issue with all ### Issues -Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the code and have the following structure: - -```php -/** - * @todo Orange-Management/Orange-Management#ISSUE_NUMBER [d:difficulty] - * Description for the issue - */ -``` +Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the `Project.md` file in the `Docs` repository. The issue information can be used to provide additional information such as priority, difficulty and type. For your first issue try to find a issue marked `[d:first]` or `[d:beginner]`. diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 7cfabe8..53333d2 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -528,7 +528,6 @@ final class ApiController extends Controller } // handle Routes of already installed modules - // @todo: what about navigation links, works for Api and Backend but only since the Navigation module is installed afterwards. Other applications don't have this and would not have the links? foreach ($installed as $module => $data) { $class = '\Modules\\' . $module . '\Admin\Installer'; @@ -1140,6 +1139,15 @@ final class ApiController extends Controller $queryLoad->execute(); } + // install receiving from application (receiving from module is already installed during the module installation) + $appManager = new ApplicationManager($this->app); + $receiving = $appManager->getProvidingForModule($module); + foreach ($receiving as $app => $modules) { + foreach ($modules as $module) { + $this->app->moduleManager->installProviding('/Web/' . $app, $module); + } + } + break; case ModuleStatusUpdateType::UNINSTALL: $done = $module === 'Admin' ? false : $this->app->moduleManager->uninstall($module); @@ -1657,10 +1665,8 @@ final class ApiController extends Controller * * @api * - * @todo Orange-Management/Modules#64 - * Create update functionality - * * @since 1.0.0 + * @todo implement */ public function apiCheckForUpdates(RequestAbstract $request, ResponseAbstract $response, $data = null) : void {