/** * 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(); }
/** * Instantiate a new object * * @param WebRequest $request optional WebRequest object */ public function __construct(WebRequest $request = null) { // turn off automatic session starting (if enabled) ini_set('session.auto_start', '0'); if (is_null($request)) { $request = WebRequest::createFromGlobals(); } // Store the request $this->request = $request; parent::__construct(); Logger::debug(sprintf('Web Request: %s', $request->getPathInfo())); }