You are here

protected function CourseObjectStorage::mapFromStorageRecords in Course 8.3

Same name and namespace in other branches
  1. 8.2 src/Storage/CourseObjectStorage.php \Drupal\course\Storage\CourseObjectStorage::mapFromStorageRecords()
  2. 3.x src/Storage/CourseObjectStorage.php \Drupal\course\Storage\CourseObjectStorage::mapFromStorageRecords()

When loading from the database, map any object to its respective class.

Overrides SqlContentEntityStorage::mapFromStorageRecords

File

src/Storage/CourseObjectStorage.php, line 33

Class

CourseObjectStorage

Namespace

Drupal\course\Storage

Code

protected function mapFromStorageRecords(array $records, $load_from_revision = FALSE) {
  $available = course_get_handlers();
  $out = [];
  foreach ($records as $id => $record) {
    $ret = $available[$record->object_type];
    if ($ret['class']) {
      $this->entityClass = $ret['class'];
    }
    else {
      $this->entityClass = 'Drupal\\course\\Course\\Object\\CourseObjectBroken';
    }
    $entities = parent::mapFromStorageRecords([
      $id => $record,
    ], $load_from_revision);
    $out += $entities;
  }
  return $out;
}