You are here

class EntityServicePreferenceEvent in Avatar Kit 8.2

Used to determine the preference order of avatar services for an entity.

Hierarchy

Expanded class hierarchy of EntityServicePreferenceEvent

See also

\Drupal\avatars\Event\AvatarKitEvents::ENTITY_SERVICE_PREFERENCE

3 files declare their use of EntityServicePreferenceEvent
AvatarKitDefaultPreferenceSubscriber.php in src/EventSubscriber/AvatarKitDefaultPreferenceSubscriber.php
AvatarKitEntityFieldPreferenceSubscriber.php in src/EventSubscriber/AvatarKitEntityFieldPreferenceSubscriber.php
AvatarKitEntityPreferenceManager.php in src/AvatarKitEntityPreferenceManager.php

File

src/Event/EntityServicePreferenceEvent.php, line 13

Namespace

Drupal\avatars\Event
View source
class EntityServicePreferenceEvent extends Event {

  /**
   * An array of weights keyed by avatar service entity ID's.
   *
   * Lower value weights are higher priority.
   *
   * @var int[]
   */
  protected $services;

  /**
   * The entity to get preferences.
   *
   * @var \Drupal\Core\Entity\EntityInterface
   */
  protected $entity;

  /**
   * Get weights for avatar services.
   *
   * @return string[]
   *   An array of weights keyed by avatar service entity ID's.
   */
  public function getServices() : array {
    return $this->services;
  }

  /**
   * Sets weights for avatar services.
   *
   * @param string[] $services
   *   An array of weights keyed by avatar service entity ID's.
   *
   * @return $this
   *   Returns this event for chaining.
   */
  public function setServices(array $services) : self {
    $this->services = $services;
    return $this;
  }

  /**
   * Get the entity preferences are being set for.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity preferences are being set for.
   */
  public function getEntity() : EntityInterface {
    return $this->entity;
  }

  /**
   * Set the entity preferences are being set for.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity preferences are being set for.
   *
   * @return $this
   *   Returns this event for chaining.
   */
  public function setEntity(EntityInterface $entity) : self {
    $this->entity = $entity;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityServicePreferenceEvent::$entity protected property The entity to get preferences.
EntityServicePreferenceEvent::$services protected property An array of weights keyed by avatar service entity ID's.
EntityServicePreferenceEvent::getEntity public function Get the entity preferences are being set for.
EntityServicePreferenceEvent::getServices public function Get weights for avatar services.
EntityServicePreferenceEvent::setEntity public function Set the entity preferences are being set for.
EntityServicePreferenceEvent::setServices public function Sets weights for avatar services.