Attaches data to entities upon loading.

This will attach fields, if the entity is fieldable. It calls hook_entity_load() for modules which need to add data to all entities. It also calls hook_TYPE_load() on the loaded entities. For example hook_node_load() or hook_user_load(). If your hook_TYPE_load() expects special parameters apart from the queried entities, you can set $this->hookLoadArguments prior to calling the method. See NodeController::attachLoad() for an example.

Parameters

$queried_entities: Associative array of query results, keyed on the entity ID.

$revision_id: ID of the revision that was loaded, or FALSE if the most current revision was loaded.

Overrides DrupalDefaultEntityController::attachLoad

File

modules/node/node.module, line 4159
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Class

NodeController
Controller class for nodes.

Code

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

  // Create an array of nodes for each content type and pass this to the
  // object type specific callback.
  $typed_nodes = array();
  foreach ($nodes as $id => $entity) {
    $typed_nodes[$entity->type][$id] = $entity;
  }

  // Call object type specific callbacks on each typed array of nodes.
  foreach ($typed_nodes as $node_type => $nodes_of_type) {
    if (node_hook($node_type, 'load')) {
      $function = node_type_get_base($node_type) . '_load';
      $function($nodes_of_type);
    }
  }

  // Besides the list of nodes, pass one additional argument to
  // hook_node_load(), containing a list of node types that were loaded.
  $argument = array_keys($typed_nodes);
  $this->hookLoadArguments = array(
    $argument,
  );
  parent::attachLoad($nodes, $revision_id);
}