You are here

function replicate_clone_fields in Replicate 7

Replicate the fields of an entity.

Parameters

object $entity: The entity for which to clone the fields.

string $entity_type: The entity type.

1 call to replicate_clone_fields()
replicate_clone_entity in ./replicate.module
Replicate the entity passed in argument.

File

./replicate.module, line 136
Main methods of Replicate module.

Code

function replicate_clone_fields(&$entity, $entity_type) {
  foreach (field_info_fields() as $field_name => $field) {
    if (isset($entity->{$field_name})) {

      // Here call hook functions. Doesn't use module_invoke because we
      // want to pass the clone by reference.
      foreach (module_implements('replicate_field_' . $field['type']) as $module) {
        $function = $module . '_replicate_field_' . $field['type'];
        $function($entity, $entity_type, $field_name);
      }
    }
  }
}