0

Here in the documentation comment for entity_export() says:

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

So, what does it actually mean?

Background info: We are going to create two modules. One for defining an entity type using hook_entity_info() and other providing UI for adding, editing, managing etc. There will be two drupal 7 installations. One will be installed with both of above modules and other only with first module defining entity type.

On first drupal installation, we will be creating/editing entities of type what we defined. And exported to second installation. So, we are checking for the capabilities of entity_export() and entity_import() functions for integration of entity export/import functionality.

2

The CRUD API is the set of functions that allows an entity to be Created, Readed, Updated and Deleted.

An entity has a CRUD API when its entity controller implementes de EntityAPIControllerInterface. The EntityAPIController class, the default Entity API entity controller class implements this interface.

So you only have to define your entity using the Entity API contrib module and use that class as controller (or your custom subclass of that class).

If you read the entity_export code you can see:

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

The function checks if the entity controller implements EntityAPIControllerInterface interface; if yes the export method is called.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.