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) { $data = config($module->alias); $data['active'] = $module->enabled; // path to module.json $path = config('modules.paths.modules') . DIRECTORY_SEPARATOR . $data['name'] . DIRECTORY_SEPARATOR . 'module.json'; if (!is_writable($path)) { throw new \ErrorException('Cannot write to ' . $path . '. Module ' . $data['name'] . ' cannot be enabled.'); } // create file file_put_contents($path, json_encode($data)); } }