You are here

public function AvatarPreview::setAvatar in Avatar Kit 8

Set associated avatar file.

Parameters

\Drupal\file\FileInterface|null $file: A file entity, or NULL if the generator did not create an avatar.

Return value

\Drupal\avatars\AvatarPreviewInterface Return avatar preview for chaining.

Overrides AvatarPreviewInterface::setAvatar

File

src/Entity/AvatarPreview.php, line 68

Class

AvatarPreview
Defines the avatar preview entity.

Namespace

Drupal\avatars\Entity

Code

public function setAvatar(FileInterface $file = NULL) {
  $this
    ->set('avatar', [
    'entity' => $file,
  ]);

  // @todo: change usage on save.
  return $this;
}