You are here

public function AvatarKitEntityFieldHandler::getAvatarFieldConfig in Avatar Kit 8.2

Get target field configuration for an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: Get the field for this entity.

Return value

\Drupal\field\FieldConfigInterface|null A field config entity, or NULL if one does not exist for this entity.

Overrides AvatarKitEntityFieldHandlerInterface::getAvatarFieldConfig

File

src/AvatarKitEntityFieldHandler.php, line 103

Class

AvatarKitEntityFieldHandler
Handles pushing avatar caches into entities.

Namespace

Drupal\avatars

Code

public function getAvatarFieldConfig(EntityInterface $entity) : ?FieldConfigInterface {
  $field_name = $this
    ->getAvatarFieldName($entity);
  if (!$field_name) {
    return NULL;
  }
  $field_config_id = $entity
    ->getEntityTypeId() . '.' . $entity
    ->bundle() . '.' . $field_name;
  $field_config = FieldConfig::load($field_config_id);
  return $field_config ? $field_config : NULL;
}