[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/restful/src/RESTful/ -> Collection.php (source)

   1  <?php
   2  
   3  namespace RESTful;
   4  
   5  class Collection extends Itemization
   6  {
   7      public function __construct($resource, $uri, $data = null)
   8      {
   9          parent::__construct($resource, $uri, $data);
  10          $this->_parseUri();
  11      }
  12  
  13      private function _parseUri()
  14      {
  15          $parsed = parse_url($this->uri);
  16          $this->_uri = $parsed['path'];
  17          if (array_key_exists('query', $parsed)) {
  18              foreach (explode('&', $parsed['query']) as $param) {
  19                  $param = explode('=', $param);
  20                  $key = urldecode($param[0]);
  21                  $val = (count($param) == 1) ? null : urldecode($param[1]);
  22  
  23                  // size
  24                  if ($key == 'limit') {
  25                      $this->_size = $val;
  26                  }
  27              }
  28          }
  29      }
  30  
  31      public function create($payload)
  32      {
  33          $class = $this->resource;
  34          $client = $class::getClient();
  35          $response = $client->post($this->uri, $payload);
  36  
  37          return new $this->resource($response->body);
  38      }
  39  
  40      public function query()
  41      {
  42          return new Query($this->resource, $this->uri);
  43      }
  44  
  45      public function paginate()
  46      {
  47          return new Pagination($this->resource, $this->uri);
  48      }
  49  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1