/** * {@inheritdoc} */ 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)); } }