[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/balanced-php/src/Balanced/ -> Resource.php (source)

   1  <?php
   2  
   3  namespace Balanced;
   4  
   5  use Balanced\Errors\Error;
   6  use RESTful\Exceptions\HTTPError;
   7  
   8  class Resource extends \RESTful\Resource
   9  {
  10      public static $fields, $f;
  11      
  12      protected static $_client, $_registry, $_uri_spec;
  13      
  14      public static function init()
  15      {
  16          self::$_client = new \RESTful\Client('\Balanced\Settings', null, __NAMESPACE__ .'\Resource::convertError');
  17          self::$_registry = new \RESTful\Registry();
  18          self::$f = self::$fields = new \RESTful\Fields();
  19      }
  20      
  21      public static function convertError($response)
  22      {
  23          if (property_exists($response->body, 'category_code') &&
  24              array_key_exists($response->body->category_code, Error::$codes))
  25              $error = new Error::$codes[$response->body->category_code]($response);
  26          else
  27              $error = new HTTPError($response);
  28          return $error;
  29      }
  30      
  31      public static function getClient()
  32      {
  33          $class = get_called_class();
  34          return $class::$_client;
  35      }
  36      
  37      public static function getRegistry()
  38      {
  39          $class = get_called_class();
  40          return $class::$_registry;
  41      }
  42      
  43      public static function getURISpec()
  44      {
  45          $class = get_called_class();
  46          return $class::$_uri_spec;
  47      }
  48  }


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