You are here

function entity_export in Entity API 7

Exports an entity.

Note: Currently, this only works for entity types provided with the entity CRUD API.

Parameters

$entity_type: The type of the entity.

$entity: The entity to export.

$prefix: An optional prefix for each line.

Return value

string The exported entity as serialized string. The format is determined by the respective entity controller, e.g. it is JSON for the EntityAPIController. The output is suitable for entity_import().

2 calls to entity_export()
EntityDefaultFeaturesController::export_render in ./entity.features.inc
Generates the result for hook_features_export_render().
EntityDefaultUIController::operationForm in includes/entity.ui.inc
Builds the operation form.

File

./entity.module, line 497

Code

function entity_export($entity_type, $entity, $prefix = '') {
  if (method_exists($entity, 'export')) {
    return $entity
      ->export($prefix);
  }
  $info = entity_get_info($entity_type);
  if (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
    return entity_get_controller($entity_type)
      ->export($entity, $prefix);
  }
}