Esempio n. 1
0
 /**
  *  do custom initialization stuff
  *
  *  @since  7-25-11
  *  @see  parent::initialize for params      
  */
 public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
 {
     $cli_query = null;
     if (!empty($server['argv'])) {
         $cli = $server['argv'];
         // in a real cli request, the 0 will be the script, in a http request, 0 will be the query string
         // but we only care about argv if it has more than the first item...
         if (isset($cli[1])) {
             $cli_query = new \ParseOpt($cli);
             // treat all the key/vals as query vars...
             if ($cli_query->hasFields()) {
                 $query = array_merge($query, $cli_query->getFields());
             }
             //if
         }
         //if
     }
     //if
     ///\out::e($query, $request, $attributes, $cookies, $files, $server, $content);
     parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
     // treat any cli vals as appendages to the path...
     if (!empty($cli_query) && $cli_query->hasList()) {
         // this overrides automagic path finding...
         $this->pathInfo = join('/', $cli_query->getList());
     }
     //if
 }
Esempio n. 2
0
 public function testParseList()
 {
     $argv = array();
     $argv[] = 'one';
     $argv[] = 'two';
     $po = new ParseOpt($argv);
     $this->assertEmpty($po->getFields());
     $this->assertEquals(2, count($po->getList()));
 }