Example #1
0
 public function testPath()
 {
     $path = new Simples_Path('/root/');
     $this->assertEquals('/root/', (string) $path);
     $path->directory('sub');
     $this->assertEquals('/root/sub/', (string) $path);
     $path->param('param', 'value');
     $this->assertEquals('/root/sub/?param=value', (string) $path);
     $path->params(array('other' => 'value'));
     $this->assertEquals('/root/sub/?param=value&other=value', (string) $path);
     $path->directories(array('other', 'again'));
     $this->assertEquals('/root/sub/other/again/?param=value&other=value', (string) $path);
 }
Example #2
0
 /**
  * Path : id management.
  *
  * @return string	API path
  */
 public function path()
 {
     if ($this->multiple()) {
         $path = new Simples_Path('_mget');
         if ($this->definition()->inject('params')) {
             $path->params($this->params());
         }
     } else {
         $path = parent::path();
         // Object id transmited : we had it to the url.
         if (isset($this->_body['id'])) {
             $path->directory($this->_body['id']);
         }
     }
     return $path;
 }
Example #3
0
 /**
  * Path : id management.
  *
  * @return string	API path
  */
 public function path()
 {
     if ($this->bulk()) {
         $path = new Simples_Path('_bulk');
         if ($this->definition()->inject('params')) {
             $path->params($this->params());
         }
     } else {
         $path = parent::path();
         // Object id transmited : we had it to the url.
         if (isset($this->_options['id'])) {
             $path->directory($this->_options['id']);
         } elseif ($this->_body instanceof Simples_Document) {
             if ($this->_body->id) {
                 $path->directory($this->_body->id);
             } elseif ($this->_body->properties() && $this->_body->properties()->id) {
                 $path->directory($this->_body->properties()->id);
             }
         }
     }
     return $path;
 }
Example #4
0
 /**
  * Returns the base path for the current request.
  * 
  * @return string 
  */
 public function path()
 {
     $path = new Simples_Path();
     $index = $this->index();
     if ($index) {
         $path->directory(trim($index, '/'));
         $type = $this->type();
         if ($type) {
             $path->directory(trim($type, '/'));
         }
     }
     if ($this->definition()->path()) {
         $path->directory(trim($this->definition()->path(), '/'));
     }
     if ($this->definition()->inject('params')) {
         $path->params($this->params());
     }
     return $path;
 }