You are here

function hook_message_digest_aggregate_alter in Message Digest 8

Allow modules to messages being aggregated for digests.

Parameters

array $context: An array consisting of the following data:

  • 'data': The raw result row from the `message_digest` table.
  • 'entity_type': The entity type. Set to an empty string to switch to a global digest (eg, un-grouped).
  • 'entity_id': The entity ID. Set to an empty string to switch to a global digest (eg, un-grouped).
  • 'messages': An array of messages to be sent. These are in the order they'll appear in the digest, so can be re-arranged/sorted as needed.

\Drupal\user\UserInterface $account: The user account object the digests are being gathered for.

\Drupal\message_notify\Plugin\Notifier\MessageNotifierInterface $notifier: The notifier plugin being used.

1 function implements hook_message_digest_aggregate_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

message_digest_test_message_digest_aggregate_alter in tests/modules/message_digest_test/message_digest_test.module
Implements hook_message_digest_aggregate_alter().
1 invocation of hook_message_digest_aggregate_alter()
DigestManager::processSingleUserDigest in src/DigestManager.php
Processes and sends an individual digest for a given user.

File

./message_digest.api.php, line 28
Hooks provided by the Message Digest module.

Code

function hook_message_digest_aggregate_alter(array &$context, UserInterface $account, MessageNotifierInterface $notifier) {

  // Aggregate all content into one digest by setting gid to 0 for users that
  // have opted in via a field called `aggregate_content`, and if this is the
  // weekly digest.
  if ($account->aggregate_content->value && $notifier
    ->getPluginId() === 'message_digest:weekly') {
    $context['gid'] = 0;
  }
}