Example #1
0
 public static function configure(&$config = NULL, LogInterface &$log)
 {
     $config = new ControllerConfig($config);
     $log->info('[ Controller configuration ]');
     do {
         try {
             $config->setName(Cmd::readInput('name>', $log));
         } catch (\Exception $e) {
             $log->error($e->getMessage());
         }
     } while (!$config->getName());
     $controller = new Controller($config, $validate = 'soft');
     AssetCli::addAssetsToObject($config, 'Add project assets', 'Add assets at a controller level. This means that every asset you add here will be present in each acton of this controller', $log);
     do {
         $log->info('Add actions to your controller.');
         $opt = Cmd::selectWithKeys(array('N' => 'New Action', 'E' => 'End adding actions'), '>', $log);
         if (strtolower($opt) == 'e') {
             break;
         }
         $actionConfig = new ActionConfig();
         $actionConfig->setController($controller);
         $config->addAction(Action::cliConfig($actionConfig, $log));
     } while (TRUE);
     return $controller;
 }
Example #2
0
 public static function configure(&$config = NULL, LogInterface &$log)
 {
     $config = new JSAssetConfig($config);
     $config = parent::configure($config, $log);
     return new Javascript($config, $validate = 'soft');
 }
Example #3
0
 public static function configureProject(&$config, LogInterface &$log)
 {
     $title = $config ? sprintf('Edit project < %s >', $config->getName()) : 'New project';
     $config = new ProjectConfig($config);
     $project = new Project($config, $validate = 'none');
     do {
         Cmd::clear();
         $hasName = $config->getName();
         $directoriesConfigured = $config->getDirectories() && $config->getDirectories()->isValidated();
         $options = array('N' => array('value' => sprintf('Project name (%s)', $hasName ? $config->getName() : ''), 'color' => $hasName ? 'light_green' : 'yellow'), 'D' => array('value' => sprintf('Directories %s', $directoriesConfigured ? '(configured)' : $hasName ? '' : '(Set project name first)'), 'color' => $directoriesConfigured ? 'light_green' : ($hasName ? 'yellow' : 'gray')), 'C' => 'Connections', 'A' => 'Assets');
         $enableModulesEntry = $hasName && $config->getDirectories();
         $modulesColor = $enableModulesEntry ? 'yellow' : 'gray';
         $options['M'] = array('color' => $modulesColor, 'value' => $enableModulesEntry ? 'Modules' : 'Modules (configure name and directories first)');
         $options['S'] = 'Save';
         $options['B'] = 'Back';
         try {
             Cmd::clear();
             $log->success("[ {$title} ]");
             $log->repeat('-', '80', 'light_purple');
             $log->debug("Project {$config->getName()}>");
             $log->repeat('-', '80', 'light_purple');
             $option = Cmd::selectWithKeys($options, '>', $log);
             switch (strtolower($option)) {
                 //Configure project name
                 case 'n':
                     self::configureName($config, $log);
                     break;
                     //Configure Assets
                 //Configure Assets
                 case 'a':
                     $help = 'Add assets at a project level. This means that every asset you add here will be ';
                     $help = sprintf('%s present in each controller or action', $help);
                     AssetCli::assetConfiguration($config, 'Project assets', $help, $log);
                     break;
                     //Configure project directories
                 //Configure project directories
                 case 'd':
                     if (!$hasName) {
                         throw new \LogicException("You must configure the project name before configuring directories");
                     }
                     $projectDirectoriesConfig = $config->getDirectories() ? $config->getDirectories()->getConfig() : new ProjectDirectoriesConfig($noConfig = NULL);
                     $projectDirectoriesConfig->setProject($project);
                     $projectDirectoriesConfig = ProjectDirectories::cliConfig($projectDirectoriesConfig, $log);
                     if ($projectDirectoriesConfig) {
                         $config->setDirectories($projectDirectoriesConfig);
                     }
                     break;
                     //Configure connections
                 //Configure connections
                 case 'c':
                     self::configureConnections($config, $log);
                     break;
                     //Add modules to the project
                 //Add modules to the project
                 case 'm':
                     if (!$enableModulesEntry) {
                         throw new \LogicException("You must configure project name and directories before adding any modules");
                     }
                     self::configureModules($project, $log);
                     break;
                 case 'b':
                     break 2;
                     break;
                 default:
                     throw new \InvalidArgumentException("Invalid option selected");
                     break;
             }
         } catch (\Exception $e) {
             $log->error($e->getMessage());
             $log->debug($e->getTraceAsString());
             Cmd::readInput('Press enter to continue ...', $log);
         }
     } while (TRUE);
     return;
 }