コード例 #1
0
ファイル: Connection.class.php プロジェクト: pthreat/apf-dev
 protected static function dbConnectionInteractiveConfig(LogInterface &$log, Config &$config)
 {
     if (!$config instanceof Mysql5Config) {
         throw new \LogicException("Configuration object must be a mysql5 connection configuration object");
     }
     $config->setCharset(Cmd::readWithDefault('Charset:', $config->getCharset(), $log));
     $config->setSocket(Cmd::readWithDefault('Socket:', $config->getSocket(), $log));
 }
コード例 #2
0
ファイル: Cli.class.php プロジェクト: pthreat/apf-dev
 public static function configureSocket(&$config, LogInterface $log)
 {
     do {
         try {
             $config->setSocket(Cmd::readWithDefault('socket>', $config->getSocket(), $log));
         } catch (\Exception $e) {
             $log->error($e->getMessage());
         }
     } while (!$config->getSocket());
 }
コード例 #3
0
ファイル: Cli.class.php プロジェクト: pthreat/apf-dev
 public static function configurePassword(NetConfig &$config, LogInterface $log)
 {
     do {
         try {
             $config->setPassword(Cmd::readWithDefault('password>', $config->getPassword(), $log));
         } catch (\Exception $e) {
             $log->error($e->getMessage());
         }
     } while (!$config->getPassword());
 }
コード例 #4
0
ファイル: Nameable.trait.php プロジェクト: pthreat/apf-dev
 /**
  * Configure a Nameable object's name
  * Any Nameable configuration must have a configured name for it to make sense. 
  *
  * @params \apf\iface\config\Nameable	An object implementing the nameable interface
  * @params \apf\iface\Log					A log interface so we can display messages and prompts in the command line.
  * 
  */
 public static function configureName(NameableInterface &$config, LogInterface &$log)
 {
     do {
         Cmd::clear();
         $log->info('Configure name');
         $log->repeat('-', 80, 'light_purple');
         try {
             $config->setName(Cmd::readWithDefault('name>', $config->getName(), $log));
         } catch (\Exception $e) {
             $log->error($e->getMessage());
             Cmd::readInput('Press enter to continue ...');
         }
     } while (!$config->getName());
 }
コード例 #5
0
 /**
  *
  * Configure the root directory for an object implementing the RootDirectory interface.
  *
  * @params \apf\iface\RootDirectoryInterface	An object implementing the root directory interface.
  * @params \apf\iface\Log							An object implementing the log interface.
  *
  */
 public static function configureRootDirectory(RootDirectoryInterface &$config, LogInterface &$log)
 {
     do {
         try {
             Cmd::clear();
             $log->info('[ Please specify the root directory ]');
             $log->repeat('-', 80, 'light_purple');
             $dir = $config->getRootDirectory();
             $hasDir = (bool) $dir;
             if ($hasDir) {
                 $log->success("Current value: {$config->getRootDirectory()}");
                 $log->repeat('-', 80, 'light_purple');
             }
             $options = array('C' => array('value' => sprintf('%s directory (%s)', $hasDir ? 'Change' : 'Set', $dir), 'color' => $hasDir ? 'light_purple' : 'light_cyan'));
             if ($hasDir) {
                 $options['R'] = array('value' => 'Reset value', 'color' => 'yellow');
             }
             $options['B'] = 'Back';
             $opt = Cmd::selectWithKeys($options, '>', $log);
             switch (strtolower($opt)) {
                 case 'r':
                     $config->unsetRootDirectory();
                     break;
                 case 'c':
                     $config->setRootDirectory(new Dir(Cmd::readWithDefault('>', $config->getRootDirectory(), $log)));
                     break;
                 case 'b':
                     break 2;
                     break;
             }
         } catch (\Exception $e) {
             $log->error($e->getMessage());
             Cmd::readInput('Press enter to continue ...');
         }
     } while (TRUE);
     return TRUE;
 }
コード例 #6
0
ファイル: Directories.trait.php プロジェクト: pthreat/apf-dev
 /**
  *
  * Configure the root directory for an object implementing the RootDirectory interface.
  *
  * @params \apf\iface\RootDirectoryInterface	An object implementing the root directory interface.
  * @params \apf\iface\Log							An object implementing the log interface.
  *
  */
 public static function configureModuleDirectories(ModuleDirectoriesInterface &$config, LogInterface &$log)
 {
     do {
         try {
             Cmd::clear();
             $log->info('[ Please specify the modules directory ]');
             $log->repeat('-', 80, 'light_purple');
             $log->info('Press \'<\' to go back | Press \'!\' to reset this option');
             $log->repeat('-', 80, 'light_purple');
             $dir = $config->getModulesDirectory();
             if ($dir) {
                 $log->success("Current value: {$config->getModulesDirectory()}");
                 $log->repeat('-', 80, 'light_purple');
             }
             if (!$dir) {
                 $dir = new Dir(realpath(getcwd()));
                 if ($config instanceof NameableInterface) {
                     $dir->addPath($config->getName());
                 }
             }
             $opt = trim(Cmd::readWithDefault('>', $dir, $log));
             if ($opt == '<') {
                 return;
             }
             if ($opt == '!') {
                 $config->unsetModulesDirectory();
                 continue;
             }
             $config->setModulesDirectory(new Dir($opt));
         } catch (\Exception $e) {
             $log->error($e->getMessage());
             Cmd::readInput('Press enter to continue ...');
         }
     } while (!$config->getModulesDirectory());
     return TRUE;
 }