You are here

README.txt in Replicate 8

Same filename and directory in other branches
  1. 7 README.txt
Replicate module provides an API to duplicate / clone an entity.


Use:
----
Use replicate_clone_entity() function to clone an entity without saving it.
Use replicate_entity() function to clone an entity and save it at the end of
the process.
See replicate.api.php file for detailed use of hooks functions.


Very basic usage example:
--------------------------
/**
 * Replicate Basic test function.
 *
 * In this example we will suppose that there is a node with nid = 1 we want
 * to replicate.
 */
function replicate_test_function() {
  // Load a newly created node as an entity.
  $entity = array_shift(entity_load('node', array(1)));

  // Duplicate the entity and save the replica.
  replicate_entity('node', $entity);

  // You can use replicate_clone_entity() instead, alter the replica afterward
  // and manually save the entity, but if you want to implement a generic
  // code like adding ' [Replicate]' to the end of every replicated node title,
  // use the API hook hook_replicate_entity_ENTITY_TYPE().
}


Basics:
-------
Replicate provides a main cloning function, along with several hooks to control
exactly how a field is duplicated based on its type, add info after cloning,
and supports custom fields and entities. It is intended to developers and does
not contain any GUI (for the moment anyway).

The goal is to provide a way to easily clone any entity, and to allow developers
to be able to control exactly how entities are replicated, based on their type
or the fields they contain, and to be able to easily extend the replication
control to custom fields or entities.


But there already is a Node Clone module!
-----------------------------------------
The Node Clone module focus on cloning using the administration interface and is
designed only for nodes replication, whereas Replicate can clone any entities
(nodes, taxonomy terms, ...). Replicate is developer-oriented, and let you
manage the cloning process the way you want.
Node Clone has also only one hook to alter cloned nodes, Replicate provides
several hooks to be able to work on a specific entity type or field type and
thus writing the smallest amount of code required.


Why do I need Replicate module on my project?
---------------------------------------------
You need Replicate if you have the need to clone / duplicate content on your
site and if you want to have full control over how entities are replicated,
and write specific replication process.
For example modules can be easily written to extend Replicate functionalities to
manage node references when duplicating a node in another language so that the
node references reference translated contents and not the original referenced
nodes.
Or to tell Drupal how to duplicate the super field you created and use on
taxonomy terms.

This module was originally developed for a big project involving a complex
replication workflow, where a global site is creating and publishing content and
sent it to sub-sites in several other languages to be translated.
The contents are very complex and use a lot of node references and field
collections.


What else?
----------
Dependencies:
-Entity API

Replicate already implements basic replication cleaning functions for the
Drupal core entities:
-Nodes
-Taxonomy Vocabularies
-Taxonomy Terms
-Comments
-Files

See also:
Replicate Field Collection (https://drupal.org/project/replicate_field_collection)

Thanks:
Thanks to Vincent Bouchet (https://drupal.org/u/vbouchet) for his help on the coding and testing of this module.
Module development sponsorized by Capgemini Drupal Factory.

File

README.txt
View source
  1. Replicate module provides an API to duplicate / clone an entity.
  2. Use:
  3. ----
  4. Use replicate_clone_entity() function to clone an entity without saving it.
  5. Use replicate_entity() function to clone an entity and save it at the end of
  6. the process.
  7. See replicate.api.php file for detailed use of hooks functions.
  8. Very basic usage example:
  9. --------------------------
  10. /**
  11. * Replicate Basic test function.
  12. *
  13. * In this example we will suppose that there is a node with nid = 1 we want
  14. * to replicate.
  15. */
  16. function replicate_test_function() {
  17. // Load a newly created node as an entity.
  18. $entity = array_shift(entity_load('node', array(1)));
  19. // Duplicate the entity and save the replica.
  20. replicate_entity('node', $entity);
  21. // You can use replicate_clone_entity() instead, alter the replica afterward
  22. // and manually save the entity, but if you want to implement a generic
  23. // code like adding ' [Replicate]' to the end of every replicated node title,
  24. // use the API hook hook_replicate_entity_ENTITY_TYPE().
  25. }
  26. Basics:
  27. -------
  28. Replicate provides a main cloning function, along with several hooks to control
  29. exactly how a field is duplicated based on its type, add info after cloning,
  30. and supports custom fields and entities. It is intended to developers and does
  31. not contain any GUI (for the moment anyway).
  32. The goal is to provide a way to easily clone any entity, and to allow developers
  33. to be able to control exactly how entities are replicated, based on their type
  34. or the fields they contain, and to be able to easily extend the replication
  35. control to custom fields or entities.
  36. But there already is a Node Clone module!
  37. -----------------------------------------
  38. The Node Clone module focus on cloning using the administration interface and is
  39. designed only for nodes replication, whereas Replicate can clone any entities
  40. (nodes, taxonomy terms, ...). Replicate is developer-oriented, and let you
  41. manage the cloning process the way you want.
  42. Node Clone has also only one hook to alter cloned nodes, Replicate provides
  43. several hooks to be able to work on a specific entity type or field type and
  44. thus writing the smallest amount of code required.
  45. Why do I need Replicate module on my project?
  46. ---------------------------------------------
  47. You need Replicate if you have the need to clone / duplicate content on your
  48. site and if you want to have full control over how entities are replicated,
  49. and write specific replication process.
  50. For example modules can be easily written to extend Replicate functionalities to
  51. manage node references when duplicating a node in another language so that the
  52. node references reference translated contents and not the original referenced
  53. nodes.
  54. Or to tell Drupal how to duplicate the super field you created and use on
  55. taxonomy terms.
  56. This module was originally developed for a big project involving a complex
  57. replication workflow, where a global site is creating and publishing content and
  58. sent it to sub-sites in several other languages to be translated.
  59. The contents are very complex and use a lot of node references and field
  60. collections.
  61. What else?
  62. ----------
  63. Dependencies:
  64. -Entity API
  65. Replicate already implements basic replication cleaning functions for the
  66. Drupal core entities:
  67. -Nodes
  68. -Taxonomy Vocabularies
  69. -Taxonomy Terms
  70. -Comments
  71. -Files
  72. See also:
  73. Replicate Field Collection (https://drupal.org/project/replicate_field_collection)
  74. Thanks:
  75. Thanks to Vincent Bouchet (https://drupal.org/u/vbouchet) for his help on the coding and testing of this module.
  76. Module development sponsorized by Capgemini Drupal Factory.