Beispiel #1
0
 public function __construct($endpoint_name)
 {
     module_load_include('inc', 'services', 'services.runtime');
     $this->endpoint_name = $endpoint_name;
     $endpoint = services_endpoint_load($this->endpoint_name);
     $server = $endpoint->server;
     services_set_server_info_from_array(array('module' => $server, 'endpoint' => $this->endpoint_name, 'endpoint_path' => $endpoint->path, 'debug' => $endpoint->debug, 'settings' => $endpoint->server_settings));
     $this->server = new \RESTServer();
 }
Beispiel #2
0
 /**
  * Default constructor.
  *
  * @param string $endpoint_name
  *   Name of the endpoint. This is the path for the server, for e.g. "rest".
  */
 public function __construct($endpoint_name)
 {
     module_load_include('inc', 'services', 'includes/services.runtime');
     $this->endpoint_name = $endpoint_name;
     $endpoint = services_endpoint_load($this->endpoint_name);
     $server = $endpoint->server;
     services_set_server_info_from_array(array('module' => $server, 'endpoint' => $this->endpoint_name, 'endpoint_path' => $endpoint->path, 'debug' => $endpoint->debug, 'settings' => $endpoint->server_settings));
     $this->endpoint_path = services_get_server_info('endpoint_path', 'services/rest');
     $services_rest_server_factory = variable_get('services_rest_server_factory_class', 'ServicesRESTServerFactory');
     $this->rest_server_factory = new $services_rest_server_factory(array('endpoint_path' => $this->endpoint_path));
 }
 function endpoint()
 {
     $path = '';
     if ($endpoint = services_endpoint_load('xlms_session')) {
         $path = url($endpoint->path . '/' . $endpoint->name, array('absolute' => TRUE));
     }
     // Add our id to the URL so Chrome app doesn't need to parse anything.
     if ($this->id) {
         $path .= '/' . $this->id;
     }
     return $path;
 }
/**
 * services_edit_endpoint_resources function.
 *
 * Edit Resources endpoint form
 * @param object $endpoint
 * @return string  The form to be displayed
 */
function services_edit_endpoint_resources($endpoint)
{
    if (!is_object($endpoint)) {
        $endpoint = services_endpoint_load($endpoint);
    }
    if ($endpoint && !empty($endpoint->title)) {
        drupal_set_title($endpoint->title);
    }
    return drupal_get_form('services_edit_form_endpoint_resources', $endpoint);
}
 public function saveNewEndpoint()
 {
     $edit = $this->populateEndpointFAPI();
     $endpoint = new stdClass();
     $endpoint->disabled = FALSE;
     /* Edit this to true to make a default endpoint disabled initially */
     $endpoint->api_version = 3;
     $endpoint->name = $edit['name'];
     $endpoint->title = $edit['title'];
     $endpoint->server = $edit['server'];
     $endpoint->path = $edit['path'];
     $endpoint->authentication = array('services_sessauth' => array());
     $endpoint->resources = array('node' => array('alias' => '', 'operations' => array('create' => array('enabled' => 1), 'retrieve' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1), 'index' => array('enabled' => 1))), 'system' => array('alias' => '', 'actions' => array('connect' => array('enabled' => 1), 'get_variable' => array('enabled' => 1), 'set_variable' => array('enabled' => 1))), 'taxonomy_term' => array('alias' => '', 'operations' => array('create' => array('enabled' => 1), 'retrieve' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1)), 'actions' => array('selectNodes' => array('enabled' => 1))), 'taxonomy_vocabulary' => array('alias' => '', 'operations' => array('create' => array('enabled' => 1), 'retrieve' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1)), 'actions' => array('getTree' => array('enabled' => 1))), 'user' => array('alias' => '', 'operations' => array('create' => array('enabled' => 1), 'retrieve' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1), 'index' => array('enabled' => 1)), 'actions' => array('login' => array('enabled' => 1), 'logout' => array('enabled' => 1))), 'comment' => array('alias' => '', 'operations' => array('create' => array('enabled' => 1), 'retrieve' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1)), 'actions' => array('loadNodeComments' => array('enabled' => 1), 'countAll' => array('enabled' => 1), 'countNew' => array('enabled' => 1))), 'file' => array('alias' => '', 'operations' => array('create' => array('enabled' => 1), 'retrieve' => array('enabled' => 1), 'delete' => array('enabled' => 1)), 'actions' => array('nodeFiles' => array('enabled' => 1))), 'echo' => array('alias' => '', 'operations' => array('index' => array('enabled' => 1))));
     $endpoint->debug = 1;
     $endpoint->status = 1;
     services_endpoint_save($endpoint);
     $endpoint = services_endpoint_load($endpoint->name);
     if ($endpoint->name == $edit['name']) {
         $this->pass('Endpoint successfully created');
     } else {
         $this->fail('Endpoint creation failed');
     }
     $this->servicesGet($endpoint->path);
     return $endpoint;
 }
 public function saveNewEndpoint()
 {
     $edit = $this->populateEndpointFAPI();
     $endpoint = new stdClass();
     $endpoint->disabled = FALSE;
     /* Edit this to true to make a default endpoint disabled initially */
     $endpoint->api_version = 3;
     $endpoint->name = $edit['name'];
     $endpoint->title = $edit['title'];
     $endpoint->server = $edit['server'];
     $endpoint->path = $edit['path'];
     $endpoint->authentication = array('services' => 'services');
     $endpoint->server_settings = array('rest_server' => array('formatters' => array('json' => TRUE, 'bencode' => TRUE, 'rss' => TRUE, 'plist' => TRUE, 'xmlplist' => TRUE, 'php' => TRUE, 'yaml' => TRUE, 'jsonp' => FALSE, 'xml' => FALSE), 'parsers' => array('application/x-yaml' => TRUE, 'application/json' => TRUE, 'application/vnd.php.serialized' => TRUE, 'application/plist' => TRUE, 'application/plist+xml' => TRUE, 'application/x-www-form-urlencoded' => TRUE)));
     $endpoint->resources = array('comment' => array('operations' => array('create' => array('enabled' => 1), 'retrieve' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1), 'index' => array('enabled' => 1)), 'actions' => array('countAll' => array('enabled' => 1), 'countNew' => array('enabled' => 1))), 'file' => array('operations' => array('create' => array('enabled' => 1), 'retrieve' => array('enabled' => 1), 'delete' => array('enabled' => 1), 'index' => array('enabled' => 1))), 'node' => array('operations' => array('retrieve' => array('enabled' => 1), 'create' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1), 'index' => array('enabled' => 1)), 'relationships' => array('files' => array('enabled' => 1), 'comments' => array('enabled' => 1))), 'system' => array('actions' => array('connect' => array('enabled' => 1), 'get_variable' => array('enabled' => 1), 'set_variable' => array('enabled' => 1), 'del_variable' => array('enabled' => 1))), 'taxonomy_term' => array('operations' => array('retrieve' => array('enabled' => 1), 'create' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1), 'index' => array('enabled' => 1)), 'actions' => array('selectNodes' => array('enabled' => 1))), 'taxonomy_vocabulary' => array('operations' => array('retrieve' => array('enabled' => 1), 'create' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1), 'index' => array('enabled' => 1)), 'actions' => array('getTree' => array('enabled' => 1))), 'user' => array('operations' => array('retrieve' => array('enabled' => 1), 'create' => array('enabled' => 1), 'update' => array('enabled' => 1), 'delete' => array('enabled' => 1), 'index' => array('enabled' => 1)), 'actions' => array('login' => array('enabled' => 1), 'logout' => array('enabled' => 1), 'register' => array('enabled' => 1))));
     $endpoint->debug = 1;
     $endpoint->export_type = FALSE;
     services_endpoint_save($endpoint);
     $endpoint = services_endpoint_load($endpoint->name);
     $this->assertTrue($endpoint->name == $edit['name'], t('Endpoint successfully created'));
     return $endpoint;
 }