Example #1
0
 /**
  * Constructor
  * @param null|string $app
  * @param null|string $event
  * @param null|string $component
  * @param array $params
  */
 public function __construct($app = null, $event = null, $component = null, array $params = array())
 {
     parent::__construct($app, $event, $component, $params);
     $path = array_shift($argv);
     $path = substr($path, 0, strrpos($path, '.php'));
     $list = explode('.', $path);
     $num = count($list);
     switch ($num) {
         case 1:
             $this->setEvent($list[0]);
             break;
         case 2:
             $this->setApplication($list[0]);
             $this->setEvent($list[1]);
             break;
         default:
             $this->setApplication($list[0]);
             $this->setComponent($list[1]);
             $this->setEvent($list[2]);
     }
     $index = 0;
     $skip = false;
     foreach ($argv as $key => $val) {
         if ($skip) {
             $skip = false;
             continue;
         }
         $next = $key + 1;
         if ($this->isOptionKey($val)) {
             $val = ltrim($val, '-');
             $value = true;
             if (!$this->isOptionKey($argv[$next])) {
                 $skip = true;
                 $value = $argv[$next];
             }
             $this->set($val, $value);
         } else {
             $this->set($index, $val);
             ++$index;
         }
     }
 }
Example #2
0
 /**
  * Returns a parameter value or the default if parameter does not exist
  * @param string $key
  * @param null|mixed $default
  * @return mixed
  */
 public function get($key, $default = null)
 {
     $ret = parent::get($key, $default);
     if ($this->getHttp()->has($key)) {
         $ret = $this->getHttp()->get($key, $default);
     }
     return $ret;
 }