/** * Update module enable attribute * * @param bool $enabled * * @return bool */ private function updateEnabled($enabled) { if ($this->enabled === $enabled) { return true; } $this->enabled = $enabled; return $this->json->update(['enabled' => $enabled]); }
/** * Install modules from modules.json file. */ private function installFromFile() { if (!file_exists($path = base_path('modules.json'))) { $this->error("File 'modules.json' does not exist in your project root."); return; } $modules = Json::make($path); $dependencies = $modules->get('require', []); foreach ($dependencies as $module) { $module = collect($module); $this->install($module->get('name'), $module->get('version'), $module->get('type')); } }
/** * Add merge modules. * * @return self */ public function addMergeModules() { $extra = array_merge($this->getExtra(), ['merge-plugin' => ["include" => ["modules/*/composer.json"]]]); $this->json->set('extra', $extra)->save(); return $this; }
/** * Get & scan all modules. * * @return array */ public function scan() { $paths = $this->getScanPaths(); $modules = []; foreach ($paths as $key => $path) { $manifests = $this->app['files']->glob("{$path}/module.json"); is_array($manifests) || ($manifests = []); foreach ($manifests as $manifest) { $name = Json::make($manifest)->get('name'); $lowerName = strtolower($name); $modules[$name] = new Module($this->app, $lowerName, dirname($manifest)); } } return $modules; }