You are here

protected function WebformTokenManager::setTokenOptions in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformTokenManager.php \Drupal\webform\WebformTokenManager::setTokenOptions()

Set token option based on the entity.

Parameters

array $options: An array of token data.

\Drupal\Core\Entity\EntityInterface $entity: A Webform or Webform submission entity.

1 call to WebformTokenManager::setTokenOptions()
WebformTokenManager::replace in src/WebformTokenManager.php
Replace tokens in text.

File

src/WebformTokenManager.php, line 202

Class

WebformTokenManager
Defines a class to manage token replacement.

Namespace

Drupal\webform

Code

protected function setTokenOptions(array &$options, EntityInterface $entity) {
  $token_options = [];
  if ($entity instanceof WebformSubmissionInterface) {
    $token_options['langcode'] = $entity
      ->language()
      ->getId();
  }
  elseif ($entity instanceof WebformInterface) {
    $token_options['langcode'] = $this->languageManager
      ->getCurrentLanguage()
      ->getId();
  }
  $options += $token_options;
}