Пример #1
0
 /**
  * @param string $service_name
  * @param RESTian_Client $client
  * @param array $args
  * @throws Exception
  */
 function __construct($service_name, $client, $args = array())
 {
     $this->service_name = strtolower($service_name);
     $this->client = $client;
     /**
      * Set any defaults not set
      */
     foreach ($this->client->get_service_defaults() as $name => $value) {
         if (!isset($args[$name])) {
             $args[$name] = $value;
         }
     }
     /**
      * Allow shorthand of 'auth' for 'needs_authentication'
      */
     $args = RESTian::expand_shortnames($args, array('auth' => 'needs_authentication', 'settings' => 'settings_name'));
     /**
      * Copy properties in from $args, if they exist.
      */
     foreach ($args as $property => $value) {
         if (property_exists($this, $property)) {
             $this->{$property} = $value;
         }
     }
     /*
      * Transform from shortcut names like json and xml to valid mime type names application/json and application/xml.
      * @see: http://www.iana.org/assignments/media-types/index.html
      */
     $this->content_type = RESTian::expand_content_type($this->content_type);
     /*
      * Convert strings to arrays.
      */
     if (is_string($this->requires)) {
         $this->requires = RESTian::parse_string($this->requires);
     }
     /*
      * TODO: Note=> 'not_vars' is not yet tested.
      */
     if (is_string($this->not_vars)) {
         $this->not_vars = RESTian::parse_string($this->not_vars);
     }
     if (is_string($this->vars)) {
         $this->vars = RESTian::parse_string($this->vars);
     }
     if (isset($args['var_set'])) {
         $var_set_vars = $client->get_var_set($args['var_set']);
         $this->vars = $this->vars ? array_merge($var_set_vars, $this->vars) : $var_set_vars;
     }
 }
Пример #2
0
 /**
  * @return bool
  */
 function has_authentication()
 {
     $auth_provider = $this->client->get_auth_provider();
     return $auth_provider ? $auth_provider->is_grant($this->get_grant()) : false;
 }
Пример #3
0
 /**
  *
  */
 function _initialize_admin()
 {
     if (!$this->_admin_initialized) {
         if (!method_exists($this, 'initialize_admin')) {
             trigger_error(__('Plugin must define a $plugin->initialize_admin() method..', 'sidecar'));
             exit;
         }
         $this->initialize_admin();
         $this->_admin_initialized = true;
         if ($this->_api) {
             $this->_api->maybe_set_grant($this->get_grant());
         }
     }
 }