/** * CRUD for project modules */ public static function configureModules(Project &$project, LogInterface &$log) { $projectConfig = $project->getConfig(); do { Cmd::clear(); $log->debug('[ Project modules ]'); $log->repeat('-', '80', 'light_purple'); $options = array('N' => 'New Module'); $hasModules = $projectConfig->hasModules(); if ($hasModules) { self::listModules($projectConfig, $log); $options['C'] = 'Copy module'; $options['E'] = 'Edit modules'; $options['L'] = 'List modules'; } $options['B'] = 'Back'; $opt = Cmd::selectWithKeys($options, '>', $log); switch (strtolower($opt)) { case 'n': $moduleConfig = new ModuleConfig(); $moduleConfig->setProject($project); $module = Module::cliConfig($moduleConfig, $log); if ($module) { $config->addModule($module); } break; case 'e': if ($hasModules) { self::editModules($projectConfig, $log); } break; case 'c': $module = self::copyModule($config, $log); if ($module) { $config->addModule($copy); } break; case 'l': if ($hasModules) { self::listModules($config, $log); Cmd::readInput('Press enter to continue ...'); } break; case 'd': if ($hasModules) { self::deleteModules($config, $log); } break; case 'b': break 2; break; } } while (TRUE); }
public function addModule(Module $module) { $this->modules[$module->getName()] = $module; return $this; }