1

I have an existing database (which is not under my control) that i want to use as base database for my entity. However I'm stuck at getting the data from the database. There already exists a question about this problem. However that question is only about installing the module and that doesn't apply to loading an entity.

Hope I stated my problem clear enough.

1 Answer 1

2

I think your talking about remote entity.

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.

From the Remote Entity Documentation page:

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;
}
1
  • Thanks! I hadn't seen this module. I will take a look at it!
    – Victor
    Sep 3, 2014 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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