class DeployServiceRestJSON in Deploy - Content Staging 7.3
Same name and namespace in other branches
- 7.2 plugins/DeployServiceRestJSON.inc \DeployServiceRestJSON
Class for deploying to a REST server using JSON
Hierarchy
- class \DeployServiceRest implements DeployService
- class \DeployServiceRestJSON
Expanded class hierarchy of DeployServiceRestJSON
2 string references to 'DeployServiceRestJSON'
- deploy_deploy_services in ./
deploy.deploy.inc - Implements hook_deploy_services().
- deploy_example_deploy_endpoints_default in modules/
deploy_example/ deploy_example.deploy_endpoints.inc - Implements hook_deploy_endpoints_default().
File
- plugins/
DeployServiceRestJSON.inc, line 10 - JSON REST client for deploying entities.
View source
class DeployServiceRestJSON extends DeployServiceRest {
/**
* {@inheritdoc}
*/
public function deploy(Traversable $iterator) {
foreach ($iterator as $entity) {
$json_data = drupal_json_encode($entity);
$this->config['headers']['Content-Type'] = 'application/json';
// TODO: Consider making the resource path configurable.
$url = $this->config['url'] . '/' . $entity->__metadata['uri'] . '.json';
// Temporary hack for the built-in PHP 5.4 web server that doesn't route
// filenames correctly.
// TODO: See if we can remove the .json suffix for all server. The
// Content-Type header should be enough in most (all?) cases.
if (php_sapi_name() == 'cli-server') {
$url = $this->config['url'] . '/' . $entity->__metadata['uri'];
}
$this
->httpRequest($url, 'PUT', $json_data);
}
}
/**
* {@inheritdoc}
*/
public function publish(Traversable $iterator) {
foreach ($iterator as $entity) {
$this->config['headers']['Content-Type'] = 'application/json';
// TODO: Consider making the resource path configurable.
$url = $this->config['url'] . '/' . $entity->__metadata['uri'] . '/publish';
//$this->httpRequest($url, 'POST');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeployServiceRest:: |
public | property | Configuration options. | |
DeployServiceRest:: |
public | property | An associative array of http headers for the REST request. | |
DeployServiceRest:: |
public | function |
Configuration form. Overrides DeployService:: |
|
DeployServiceRest:: |
protected | function | Fetches the context for the HTTP request. | |
DeployServiceRest:: |
public | function | Makes a HTTP request. | 1 |
DeployServiceRest:: |
public | function |
Constructor for a service plugin. Overrides DeployService:: |
1 |
DeployServiceRestJSON:: |
public | function |
Deploy all entities in the $iterator. This method should only move entities
over to the endpoint and create unpublished revisions (if supported). The
'publish' method is responsible for publishing all successfully deployed
entities. Overrides DeployServiceRest:: |
|
DeployServiceRestJSON:: |
public | function |
Publish all entities in the $iterator. This method should only publish
entities on the endpoint (if supported). The 'deploy' method is
responsible for moving the entities to the endpoint, prior to the
publishing. Overrides DeployServiceRest:: |