public function DatabaseStorageController::loadRevision

Implements Drupal\Core\Entity\EntityStorageControllerInterface::loadRevision().

Overrides EntityStorageControllerInterface::loadRevision

1 call to DatabaseStorageController::loadRevision()

File

drupal/core/lib/Drupal/Core/Entity/DatabaseStorageController.php, line 227
Definition of Drupal\Core\Entity\DatabaseStorageController.

Class

DatabaseStorageController
Defines a base entity controller class.

Namespace

Drupal\Core\Entity

Code

public function loadRevision($revision_id) {

  // Build and execute the query.
  $query_result = $this
    ->buildQuery(array(), $revision_id)
    ->execute();
  if (!empty($this->entityInfo['class'])) {

    // We provide the necessary arguments for PDO to create objects of the
    // specified entity class.
    // @see Drupal\Core\Entity\EntityInterface::__construct()
    $query_result
      ->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['class'], array(
      array(),
      $this->entityType,
    ));
  }
  $queried_entities = $query_result
    ->fetchAllAssoc($this->idKey);

  // Pass the loaded entities from the database through $this->attachLoad(),
  // which attaches fields (if supported by the entity type) and calls the
  // entity type specific load callback, for example hook_node_load().
  if (!empty($queried_entities)) {
    $this
      ->attachLoad($queried_entities, TRUE);
  }
  return reset($queried_entities);
}