You are here

class PushNotificationsMessageSenderAccounts in Push Notifications 8

Send a simple message alert to a list of tokens..

Hierarchy

Expanded class hierarchy of PushNotificationsMessageSenderAccounts

1 string reference to 'PushNotificationsMessageSenderAccounts'
push_notifications.services.yml in ./push_notifications.services.yml
push_notifications.services.yml
1 service uses PushNotificationsMessageSenderAccounts
push_notifications.message_sender_accounts in ./push_notifications.services.yml
Drupal\push_notifications\PushNotificationsMessageSenderAccounts

File

src/PushNotificationsMessageSenderAccounts.php, line 13
Contains \Drupal\push_notifications\PushNotificationsMessageSenderAccounts.

Namespace

Drupal\push_notifications
View source
class PushNotificationsMessageSenderAccounts extends PushNotificationsMessageSenderBase {

  /**
   * @var array $accounts
   *   Recipient account objects.
   */
  protected $accounts;

  /**
   * Constructor.
   *
   * @param \Drupal\push_notifications\PushNotificationsDispatcher $dispatcher
   *   Alert Dispatcher.
   */
  public function __construct(PushNotificationsDispatcher $dispatcher) {
    $this->dispatcher = $dispatcher;
  }

  /**
   * Setter function for accounts.
   *
   * @param array $accounts
   *   Account objects.
   */
  public function setAccounts($accounts) {
    $this->accounts = $accounts;
  }

  /**
   * {@inheritdoc}
   *
   * @param array $accounts
   *   Account objects.
   */
  public function generateTokens() {
    foreach ($this->accounts as $account) {
      $user_tokens = push_notification_get_user_tokens($account
        ->id());
      if (!empty($user_tokens)) {
        $this->tokens = array_merge($this->tokens, $user_tokens);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PushNotificationsMessageSenderAccounts::$accounts protected property Recipient account objects.
PushNotificationsMessageSenderAccounts::generateTokens public function Overrides PushNotificationsMessageSenderBase::generateTokens
PushNotificationsMessageSenderAccounts::setAccounts public function Setter function for accounts.
PushNotificationsMessageSenderAccounts::__construct public function Constructor. Overrides PushNotificationsMessageSenderBase::__construct
PushNotificationsMessageSenderBase::$dispatcher protected property Alert Dispatcher.
PushNotificationsMessageSenderBase::$message protected property The message that will be used in the payload.
PushNotificationsMessageSenderBase::$networks protected property Target Networks.
PushNotificationsMessageSenderBase::$results protected property Result data.
PushNotificationsMessageSenderBase::$tokens protected property List of user tokens. 1
PushNotificationsMessageSenderBase::dispatch public function Dispatch an alert.
PushNotificationsMessageSenderBase::getResults public function Getter function for results.
PushNotificationsMessageSenderBase::setMessage public function Setter function for message.
PushNotificationsMessageSenderBase::setNetworks public function Setter functions for networks.