protected function DatabaseStorageControllerNG::mapFromStorageRecords

Maps from storage records to entity objects.

Parameters

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

boolean $load_revision: (optional) TRUE if the revision should be loaded, defaults to FALSE.

Return value

array An array of entity objects implementing the EntityInterface.

2 calls to DatabaseStorageControllerNG::mapFromStorageRecords()
DatabaseStorageControllerNG::attachLoad in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Overrides DatabaseStorageController::attachLoad().
NodeStorageController::attachLoad in drupal/core/modules/node/lib/Drupal/node/NodeStorageController.php
Overrides Drupal\Core\Entity\DatabaseStorageControllerNG::attachLoad().

File

drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php, line 249
Contains \Drupal\Core\Entity\DatabaseStorageControllerNG.

Class

DatabaseStorageControllerNG
Implements Field API specific enhancements to the DatabaseStorageController class.

Namespace

Drupal\Core\Entity

Code

protected function mapFromStorageRecords(array $records, $load_revision = FALSE) {
  $entities = array();
  foreach ($records as $id => $record) {
    $entities[$id] = array();
    foreach ($record as $name => $value) {

      // Skip the item delta and item value levels but let the field assign
      // the value as suiting. This avoids unnecessary array hierarchies and
      // saves memory here.
      $entities[$id][$name][Language::LANGCODE_DEFAULT] = $value;
    }

    // If we have no multilingual values we can instantiate entity objecs
    // right now, otherwise we need to collect all the field values first.
    if (!$this->dataTable) {
      $bundle = $this->bundleKey ? $record->{$this->bundleKey} : FALSE;

      // Turn the record into an entity class.
      $entities[$id] = new $this->entityClass($entities[$id], $this->entityType, $bundle);
    }
  }
  $this
    ->attachPropertyData($entities, $load_revision);
  return $entities;
}