You are here

public function AvatarKitEntityHooks::storageLoad in Avatar Kit 8.2

Implements hook_entity_storage_load().

Overrides AvatarKitEntityHooksInterface::storageLoad

See also

\hook_entity_storage_load()

File

src/AvatarKitEntityHooks.php, line 33

Class

AvatarKitEntityHooks
Drupal entity hooks.

Namespace

Drupal\avatars

Code

public function storageLoad(array $entities) : void {
  $bin = static::class . '::' . __FUNCTION__;
  foreach ($entities as $entity) {
    if (!$entity instanceof FieldableEntityInterface) {

      // If this entity is not fieldable then none of this type are.
      return;
    }
    if ($entity
      ->isNew()) {

      // Don't deal with unsaved or skeleton entities.
      continue;
    }
    $values = [
      $entity,
    ];
    static::preventRecursion($bin, function (FieldableEntityInterface $entity) : string {
      return $entity
        ->getEntityTypeId() . ':' . $entity
        ->id();
    }, function (FieldableEntityInterface $entity) : void {
      $this
        ->entityFieldHandler()
        ->checkUpdates($entity);
    }, $values);
  }
}