You are here

interface DigestInterface in Message Digest 8

Interface for sending messages as digests.

Hierarchy

Expanded class hierarchy of DigestInterface

All classes that implement DigestInterface

4 files declare their use of DigestInterface
DigestIntervalActionDeriver.php in message_digest_ui/src/Plugin/Derivative/DigestIntervalActionDeriver.php
DigestManager.php in src/DigestManager.php
MessageDigestTrait.php in src/Traits/MessageDigestTrait.php
message_digest_ui.module in message_digest_ui/message_digest_ui.module
Hook implementations for the Message Digest UI module.

File

src/Plugin/Notifier/DigestInterface.php, line 12

Namespace

Drupal\message_digest\Plugin\Notifier
View source
interface DigestInterface extends PluginInspectionInterface, DerivativeInspectionInterface {

  /**
   * Aggregate all of the messages for this digest.
   *
   * Collect all messages for the digest's interval and notifier that haven't
   * already been sent, and group them by user and then by group.
   *
   * @param int $uid
   *   The recipient's user ID for which to aggregate the digest.
   * @param int $end_time
   *   The unix timestamp from which all messages in the past will be
   *   aggregated.
   *
   * @return array
   *   An array of message IDs for the given user, keyed by entity_type, then by
   *   entity_id.
   *
   * @code
   *   $aggregate = [
   *     '' => [
   *       // Non-grouped message digests here.
   *       12, 24,
   *     ],
   *     'node' => [
   *       23 => [1, 3, 5],
   *     ],
   *   ];
   * @endcode
   */
  public function aggregate($uid, $end_time);

  /**
   * Get a unique list of recipient user IDs for this digest.
   *
   * @return int[]
   *   An array of unique recipients for this digest.
   */
  public function getRecipients();

  /**
   * Mark the sent digest messages as sent in the message_digest DB table.
   *
   * @param \Drupal\user\UserInterface $account
   *   User account for which to mark the digest as sent.
   * @param int $last_mid
   *   The last MID to be sent in the digest.
   */
  public function markSent(UserInterface $account, $last_mid);

  /**
   * Determine if it is time to process this digest or not.
   *
   * @return bool
   *   Returns TRUE if a sufficient amount of time has passed.
   */
  public function processDigest();

  /**
   * Gets the end time for which to digest messages prior to.
   *
   * @return int
   *   The unix timestamp for which all messages prior will be digested.
   */
  public function getEndTime();

  /**
   * Sets the last sent time.
   */
  public function setLastSent();

  /**
   * The interval to compile digests for.
   *
   * @return string
   *   The interval. This should be compatible with `strtotime()`.
   */
  public function getInterval();

}

Members

Namesort descending Modifiers Type Description Overrides
DerivativeInspectionInterface::getBaseId public function Gets the base_plugin_id of the plugin instance. 1
DerivativeInspectionInterface::getDerivativeId public function Gets the derivative_id of the plugin instance. 1
DigestInterface::aggregate public function Aggregate all of the messages for this digest. 1
DigestInterface::getEndTime public function Gets the end time for which to digest messages prior to. 1
DigestInterface::getInterval public function The interval to compile digests for. 1
DigestInterface::getRecipients public function Get a unique list of recipient user IDs for this digest. 1
DigestInterface::markSent public function Mark the sent digest messages as sent in the message_digest DB table. 1
DigestInterface::processDigest public function Determine if it is time to process this digest or not. 1
DigestInterface::setLastSent public function Sets the last sent time. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2