You are here

protected function EntityAPIControllerExportable::attachLoad in Entity API 7

Overridden.

Changed to call type-specific hook with the entities keyed by name if they have one.

Overrides DrupalDefaultEntityController::attachLoad

See also

DrupalDefaultEntityController::attachLoad()

File

includes/entity.controller.inc, line 841
Provides a controller building upon the core controller but providing more features like full CRUD functionality.

Class

EntityAPIControllerExportable
A controller implementing exportables stored in the database.

Code

protected function attachLoad(&$queried_entities, $revision_id = FALSE) {

  // Attach fields.
  if ($this->entityInfo['fieldable']) {
    if ($revision_id) {
      field_attach_load_revision($this->entityType, $queried_entities);
    }
    else {
      field_attach_load($this->entityType, $queried_entities);
    }
  }

  // Call hook_entity_load().
  foreach (module_implements('entity_load') as $module) {
    $function = $module . '_entity_load';
    $function($queried_entities, $this->entityType);
  }

  // Call hook_TYPE_load(). The first argument for hook_TYPE_load() are
  // always the queried entities, followed by additional arguments set in
  // $this->hookLoadArguments.
  // For entities with a name key, pass the entities keyed by name to the
  // specific load hook.
  if ($this->nameKey != $this->idKey) {
    $entities_by_name = entity_key_array_by_property($queried_entities, $this->nameKey);
  }
  else {
    $entities_by_name = $queried_entities;
  }
  $args = array_merge(array(
    $entities_by_name,
  ), $this->hookLoadArguments);
  foreach (module_implements($this->entityInfo['load hook']) as $module) {
    call_user_func_array($module . '_' . $this->entityInfo['load hook'], $args);
  }
}