コード例 #1
0
ファイル: CliProject.php プロジェクト: chrisnoden/synergy
 /**
  * Instantiate a new CliProject object
  *
  * @param null  $request the action request notation
  * @param array $parameters parameters to pass to the action
  *
  * @throws SynergyException
  */
 public function __construct($request = null, array $parameters = array())
 {
     register_tick_function(array(&$this, "checkExit"));
     // Check this is coming from the CLI
     if (PHP_SAPI !== 'cli') {
         throw new SynergyException(sprintf('%s must be run from command line project', __CLASS__));
     }
     // Store or build the request
     $this->parameters = $parameters;
     if (!is_null($request)) {
         $this->request = $request;
     } else {
         $this->args = ArgumentParser::parseArguments();
         $this->request = $this->args->getRequest();
     }
     Logger::debug('CliProject started (pid=' . getmypid() . ')');
     if (is_null($this->args->getRequest())) {
         Logger::emergency('No controller request provided');
         exit(1);
     }
     $this->registerSignalHandler();
     if ($this->args->arg('app')) {
         $this->setAppDir($this->args->arg('app'));
     }
     if ($this->args->arg('conf')) {
         $this->setConfigFilename($this->args->arg('conf'));
     }
     parent::__construct();
 }
コード例 #2
0
ファイル: CliLogger.php プロジェクト: chrisnoden/synergy
 /**
  * Create a new FileLogger object
  *
  * @throws \Synergy\Exception\InvalidArgumentException
  */
 public function __construct()
 {
     parent::__construct();
     if (PHP_SAPI == 'cli') {
         $arg = ArgumentParser::parseArguments();
         if ($arg->hasSwitch('v')) {
             $this->_verbosity = 1;
         } else {
             if ($arg->hasSwitch('vv')) {
                 $this->_verbosity = 2;
             }
         }
     }
 }