You are here

README.txt in Entity Share 7

SUMMARY
-------

Entity Share is a module allowing you to share some content entities
like node, field_collection, taxonomy, medias etc between different
Drupal instances.

HOW DOES IT WORK
----------------

The principle of this module is to generate some export from one instance
and to send this exported datas to a remote Drupal using a server that
will import the datas.

The limitation there is that you MUST have exactly the same content types,
field_collections, taxonomy vocabularies between all your instances. 
This module manage the export of contents, not of structures 
(you can use features module to synchronise your structure for example).

INSTALLATION
------------

1. Place this module directory in your modules folder 
   (this will usually be "sites/all/modules").
2. Go to "Administer" -> "Site building" -> "Modules" and enable the module.

REQUIREMENTS
------------

- UUID (https://www.drupal.org/project/uuid)
- Entity API (https://www.drupal.org/project/entity)

CONFIGURATION
-------------

Install entity_share_ui module

USAGE
-----

If you want to use the EntityShare with Graphic Interface, 
then you should use entity_share_ui_client module.

If you just want to use the EntityShare API, 
you can use the following main classes:

 * EntityShareEntityExport
 * EntityShareEntityImport
 * EntityShareClient

Example of code to share content:
<?php
$node_id = 69;
$node = node_load($node_id);

// Export nid 69.
// We clone the node to not alter the original node object if needed after.
$export = new EntityShareEntityExport(clone $node);

// Get the node exported object, basically it's the original node
// with some sub entities loaded and some datas added for export.
$exported_node = $export->execute();


// Share the nid 69 to myendpoint.
$endpoint = 'http://myendpoint/entity_share/rest_api';

$client = new EntityShareClient($endpoint);
// Login used by entity share that must have the rights needed
// administer nodes, access entityshare server etc.
$client->login('myremotelogin', 'mypassword');

$response = $client->create('node', drupal_json_encode($exported_node));
// You get a response object containing the HTTP code of the response,
// and the json result of you export in $response->data.
if ($response->code == '200') {
  $result = drupal_json_decode($response->data);
  if ($result['status'] == 'OK') {
    // Success.
    print_r($result['result']);
  }
  else {
    // Fail.
    print_r($result['error']);
  }
}

MAINTAINERS
-----------

Current maintainers:
 * Thomas Bernard (ithom) - https://www.drupal.org/user/3175403
 * Florent Torregrosa (Grimreaper) - https://www.drupal.org/user/2388214

This project has been sponsored by:
 * Smile - http://www.smile.fr

File

README.txt
View source
  1. SUMMARY
  2. -------
  3. Entity Share is a module allowing you to share some content entities
  4. like node, field_collection, taxonomy, medias etc between different
  5. Drupal instances.
  6. HOW DOES IT WORK
  7. ----------------
  8. The principle of this module is to generate some export from one instance
  9. and to send this exported datas to a remote Drupal using a server that
  10. will import the datas.
  11. The limitation there is that you MUST have exactly the same content types,
  12. field_collections, taxonomy vocabularies between all your instances.
  13. This module manage the export of contents, not of structures
  14. (you can use features module to synchronise your structure for example).
  15. INSTALLATION
  16. ------------
  17. 1. Place this module directory in your modules folder
  18. (this will usually be "sites/all/modules").
  19. 2. Go to "Administer" -> "Site building" -> "Modules" and enable the module.
  20. REQUIREMENTS
  21. ------------
  22. - UUID (https://www.drupal.org/project/uuid)
  23. - Entity API (https://www.drupal.org/project/entity)
  24. CONFIGURATION
  25. -------------
  26. Install entity_share_ui module
  27. USAGE
  28. -----
  29. If you want to use the EntityShare with Graphic Interface,
  30. then you should use entity_share_ui_client module.
  31. If you just want to use the EntityShare API,
  32. you can use the following main classes:
  33. * EntityShareEntityExport
  34. * EntityShareEntityImport
  35. * EntityShareClient
  36. Example of code to share content:
  37. $node_id = 69;
  38. $node = node_load($node_id);
  39. // Export nid 69.
  40. // We clone the node to not alter the original node object if needed after.
  41. $export = new EntityShareEntityExport(clone $node);
  42. // Get the node exported object, basically it's the original node
  43. // with some sub entities loaded and some datas added for export.
  44. $exported_node = $export->execute();
  45. // Share the nid 69 to myendpoint.
  46. $endpoint = 'http://myendpoint/entity_share/rest_api';
  47. $client = new EntityShareClient($endpoint);
  48. // Login used by entity share that must have the rights needed
  49. // administer nodes, access entityshare server etc.
  50. $client->login('myremotelogin', 'mypassword');
  51. $response = $client->create('node', drupal_json_encode($exported_node));
  52. // You get a response object containing the HTTP code of the response,
  53. // and the json result of you export in $response->data.
  54. if ($response->code == '200') {
  55. $result = drupal_json_decode($response->data);
  56. if ($result['status'] == 'OK') {
  57. // Success.
  58. print_r($result['result']);
  59. }
  60. else {
  61. // Fail.
  62. print_r($result['error']);
  63. }
  64. }
  65. MAINTAINERS
  66. -----------
  67. Current maintainers:
  68. * Thomas Bernard (ithom) - https://www.drupal.org/user/3175403
  69. * Florent Torregrosa (Grimreaper) - https://www.drupal.org/user/2388214
  70. This project has been sponsored by:
  71. * Smile - http://www.smile.fr