createModulesJson($module); } } /** * Register the application services. * @return void */ public function register() { } /** * Read config file and merge it with module config in database. * This method REQUIRES published config of given module (otherwise config(modulename) is not available)! * * @param Module $module * * @throws \ErrorException when module.json is not writable */ private function createModulesJson(Module $module) { $config = json_decode($module->module_settings); if (is_null($config)) { return; } // path to module.json $path = config('modules.paths.modules') . DIRECTORY_SEPARATOR . $config->staticName . DIRECTORY_SEPARATOR . 'module.json'; // check if module config is writable if (!is_writable(dirname($path))) { return; } // set enabled/disabled status for this module $data = new \stdClass(); $data->name = $config->staticName; $data->description = $module->description; $data->alias = $module->alias; $data->providers = $config->providers; $data->aliases = $config->aliases; $data->order = $config->order; $data->files = $config->files; $data->active = $module->enabled; // create file file_put_contents($path, json_encode($data)); } }