You are here

protected function CommerceContentEntityStorage::postLoad in Commerce Core 8.2

Attaches data to entities upon loading.

Parameters

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

Overrides EntityStorageBase::postLoad

1 call to CommerceContentEntityStorage::postLoad()
OrderStorage::postLoad in modules/order/src/OrderStorage.php
Attaches data to entities upon loading.
1 method overrides CommerceContentEntityStorage::postLoad()
OrderStorage::postLoad in modules/order/src/OrderStorage.php
Attaches data to entities upon loading.

File

src/CommerceContentEntityStorage.php, line 80

Class

CommerceContentEntityStorage
The default Commerce storage for content entities.

Namespace

Drupal\commerce

Code

protected function postLoad(array &$entities) {
  parent::postLoad($entities);
  $event_class = $this->entityType
    ->getHandlerClass('event');
  if (!$event_class) {
    return;
  }

  // hook_entity_load() is invoked for all entities at once.
  // The event is dispatched for each entity separately, for better DX.
  // @todo Evaluate performance implications.
  $event_name = $this
    ->getEventName('load');
  foreach ($entities as $entity) {
    $this->eventDispatcher
      ->dispatch($event_name, new $event_class($entity));
  }
}