function hook_message_digest_view_mode_alter in Message Digest 8
Allow modules to change view modes prior to rendering, or stop delivery.
Parameters
array $context: An array consisting of the following data:
- 'view_modes': An array of view mode names that will be used to render the messages. Add or remove to change what information is rendered.
- 'deliver': A boolean indicating if this digest should be delivered. It defaults to TRUE. Set to FALSE to stop delivery. The digest will still be marked as being sent.
- 'entity_type': The entity type. This will be an empty string for global, non-grouped digests.
- 'entity_id': The entity ID. This will be an empty string for global, non- grouped digests.
- 'messages: An array of message IDs that are being assembled for the digest.
\Drupal\message_notify\Plugin\Notifier\MessageNotifierInterface $notifier: The message notifier being used.
\Drupal\user\UserInterface $account: The recipient of the digest.
1 function implements hook_message_digest_view_mode_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_view_mode_alter in tests/
modules/ message_digest_test/ message_digest_test.module - Implements hook_message_digest_view_mode_alter().
1 invocation of hook_message_digest_view_mode_alter()
- DigestManager::processSingleUserDigest in src/
DigestManager.php - Processes and sends an individual digest for a given user.
File
- ./
message_digest.api.php, line 58 - Hooks provided by the Message Digest module.
Code
function hook_message_digest_view_mode_alter(array &$context, MessageNotifierInterface $notifier, UserInterface $account) {
// Remove the email subject view mode.
if (isset($context['view_modes']['mail_subject'])) {
unset($context['view_modes']['mail_subject']);
}
// If the account is blocked, do not deliver.
if ($account
->isBlocked()) {
$context['deliver'] = FALSE;
}
}