You are here

function hook_sharemessage_token_context_alter in Share Message 8

Same name and namespace in other branches
  1. 7 sharemessage.api.php \hook_sharemessage_token_context_alter()

Allow other modules to alter Share Message token context.

Parameters

\Drupal\sharemessage\ShareMessageInterface $sharemessage: Currently loaded Share Message object.

array $context: Token Context.

1 invocation of hook_sharemessage_token_context_alter()
ShareMessage::getContext in src/Entity/ShareMessage.php
Gets a context for tokenizing.

File

./sharemessage.api.php, line 18
Hooks provided by Share Message module.

Code

function hook_sharemessage_token_context_alter(ShareMessageInterface $sharemessage, &$context) {

  // Alter Share Message title.
  $sharemessage->title = 'Altered Title';

  // Add taxonomy_vocabulary object type in a $context array.
  $context['taxonomy_vocabulary'] = \Drupal::routeMatch()
    ->getParameter('taxonomy_vocabulary');
}