You are here

class DeliveryCandidate in Message Subscribe 8

A delivery candidate implementation.

Hierarchy

Expanded class hierarchy of DeliveryCandidate

10 files declare their use of DeliveryCandidate
DeliveryCandidateTest.php in tests/src/Unit/Subscribers/DeliveryCandidateTest.php
fixture_foo.module.php in tests/src/fixture_foo.module.php
Test hook implementation fixture.
MessageSubscribeEmailNotificationsTest.php in message_subscribe_email/tests/src/Kernel/MessageSubscribeEmailNotificationsTest.php
MessageSubscribeEmailSubscribersTest.php in message_subscribe_email/tests/src/Kernel/MessageSubscribeEmailSubscribersTest.php
message_subscribe.api.php in ./message_subscribe.api.php
Hooks provided by the Message subscribe module.

... See full list

File

src/Subscribers/DeliveryCandidate.php, line 8

Namespace

Drupal\message_subscribe\Subscribers
View source
class DeliveryCandidate implements DeliveryCandidateInterface {

  /**
   * An array of flag IDs that triggered the notification.
   *
   * @var string[]
   */
  protected $flags = [];

  /**
   * An array of notifier IDs for delivery.
   *
   * @var string[]
   */
  protected $notifiers = [];

  /**
   * The delivery candidate account ID.
   *
   * @var int
   */
  protected $uid;

  /**
   * Constructs the delivery candidate.
   *
   * @param string[] $flags
   *   An array of flag IDs.
   * @param string[] $notifiers
   *   An array of notifier IDs.
   * @param int $uid
   *   The delivery candidate account ID.
   */
  public function __construct(array $flags, array $notifiers, $uid) {
    $this->flags = array_combine($flags, $flags);
    $this->notifiers = array_combine($notifiers, $notifiers);
    $this->uid = $uid;
  }

  /**
   * {@inheritdoc}
   */
  public function addFlag($flag_id) {
    $this->flags[$flag_id] = $flag_id;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function removeFlag($flag_id) {
    unset($this->flags[$flag_id]);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function addNotifier($notifier_id) {
    $this->notifiers[$notifier_id] = $notifier_id;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function removeNotifier($notifier_id) {
    unset($this->notifiers[$notifier_id]);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getFlags() {
    return array_unique($this->flags);
  }

  /**
   * {@inheritdoc}
   */
  public function setFlags(array $flag_ids) {
    $this->flags = array_combine($flag_ids, $flag_ids);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getNotifiers() {
    return array_unique($this->notifiers);
  }

  /**
   * {@inheritdoc}
   */
  public function setNotifiers(array $notifier_ids) {
    $this->notifiers = array_combine($notifier_ids, $notifier_ids);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getAccountId() {
    return $this->uid;
  }

  /**
   * {@inheritdoc}
   */
  public function setAccountId($uid) {
    $this->uid = $uid;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeliveryCandidate::$flags protected property An array of flag IDs that triggered the notification.
DeliveryCandidate::$notifiers protected property An array of notifier IDs for delivery.
DeliveryCandidate::$uid protected property The delivery candidate account ID.
DeliveryCandidate::addFlag public function Adds a flag. Overrides DeliveryCandidateInterface::addFlag
DeliveryCandidate::addNotifier public function Adds a notifier. Overrides DeliveryCandidateInterface::addNotifier
DeliveryCandidate::getAccountId public function Gets the account ID of the recipient. Overrides DeliveryCandidateInterface::getAccountId
DeliveryCandidate::getFlags public function Get the flags that triggered the subscription. Overrides DeliveryCandidateInterface::getFlags
DeliveryCandidate::getNotifiers public function Get the notifier IDs. Overrides DeliveryCandidateInterface::getNotifiers
DeliveryCandidate::removeFlag public function Remove a flag. Overrides DeliveryCandidateInterface::removeFlag
DeliveryCandidate::removeNotifier public function Remove a notifier. Overrides DeliveryCandidateInterface::removeNotifier
DeliveryCandidate::setAccountId public function Sets the account ID. Overrides DeliveryCandidateInterface::setAccountId
DeliveryCandidate::setFlags public function Sets the flags. Overrides DeliveryCandidateInterface::setFlags
DeliveryCandidate::setNotifiers public function Sets the notifier IDs. Overrides DeliveryCandidateInterface::setNotifiers
DeliveryCandidate::__construct public function Constructs the delivery candidate.