Last updated June 9, 2015. Created on March 7, 2013.
Edited by Frank Ralf, dobe, joachim. Log in to edit this page.

Remote Entity API provides a system for treating data from remote sites as local, Drupal entities. Remote data is stored locally in an entity base table, and can be periodically refreshed with data from the remote source.

Once a custom entity type is defined, entities can be manipulated just as normal Drupal entities: they can be loaded and saved to the local database, and have fields added to them. Remote Entity API provides ways to load an entity remotely, query the remote source for multiple entities, and save back to the remote source.

Example

Creating a connection

TODO.

Creating a resource

The Clients Resource for the remote entity type is composed of two parts, and as such can't be created in the UI:

- hook_entity_info() defines the remote entity type. See remote_entity_hook_entity_info() for the additional keys that must/can be defined here.

- The Clients resource itself must be defined with hook_clients_default_resources():

/**
 * Implements hook_clients_default_resources().
 *
 * Define our remote entity resource.
 */
function example_clients_default_resources() {
  $items['my_entity_type'] = entity_import('clients_resource', '{
    "component" : "my_entity_type",
    "connection" : "my_connection_name",
    "name" : "my_entity_type",
    "label" : "My Entity Type",
    "type" : "remote_entity", // do not change @see function remote_entity_load_by_remote_id 
    "configuration" : null,
    "rdf_mapping" : []
  }');

  return $items;
}

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.