You are here

public function AvatarKitEntityFieldHandler::checkUpdates in Avatar Kit 8.2

Checks if there are updates to the first avatar for an entity.

If an entity doesn't have an entity yet, it may get one. If it is not time to check for updates, then we will not check.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: Check this avatar if it needs a new avatar.

Overrides AvatarKitEntityFieldHandlerInterface::checkUpdates

File

src/AvatarKitEntityFieldHandler.php, line 51

Class

AvatarKitEntityFieldHandler
Handles pushing avatar caches into entities.

Namespace

Drupal\avatars

Code

public function checkUpdates(FieldableEntityInterface $entity) : void {

  // Don't try to find the first avatar when it doesnt have a target field.
  $field_name = $this
    ->getAvatarFieldName($entity);
  if (!$field_name) {
    return;
  }
  $first = $this->entityHandler
    ->findFirst($entity);
  if ($first) {
    $this
      ->copyCacheToEntity($entity, $first);
  }
}