You are here

public function TokensReplacementEvent::__construct in Hook Event Dispatcher 8

Constructor.

Parameters

string $type: The machine-readable name of the type (group) of token being replaced, such as 'node', 'user', or another type defined by a hook_token_info() implementation.

array $tokens: An array of tokens to be replaced. The keys are the machine-readable token names, and the values are the raw [type:token] strings that appeared in the original text.

array $data: An associative array of data objects to be used when generating replacement values, as supplied in the $data parameter to \Drupal\Core\Utility\Token::replace().

array $options: An associative array of options for token replacement; see \Drupal\Core\Utility\Token::replace() for possible values.

\Drupal\Core\Render\BubbleableMetadata $bubbleableMetadata: The bubbleable metadata. Prior to invoking this hook, \Drupal\Core\Utility\Token::generate() collects metadata for all of the data objects in $data. For any data sources not in $data, but that are used by the token replacement logic, such as global configuration (e.g., 'system.site') and related objects (e.g., $node->getOwner()), implementations of this hook must add the corresponding metadata.

File

src/Event/Token/TokensReplacementEvent.php, line 89

Class

TokensReplacementEvent
Class TokensProvideEvent.

Namespace

Drupal\hook_event_dispatcher\Event\Token

Code

public function __construct($type, array $tokens, array $data, array $options, BubbleableMetadata $bubbleableMetadata) {
  $this->type = $type;
  $this->tokens = $tokens;
  $this->data = $data;
  $this->options = $options;
  $this->bubbleableMetadata = $bubbleableMetadata;
}