You are here

protected function WebformTokenManager::setTokenData in Webform 6.x

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

Get token data based on an entity's type.

Parameters

array $data: An array of token data.

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

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

File

src/WebformTokenManager.php, line 181

Class

WebformTokenManager
Defines a class to manage token replacement.

Namespace

Drupal\webform

Code

protected function setTokenData(array &$data, EntityInterface $entity) {
  if ($entity instanceof WebformSubmissionInterface) {
    $data['webform_submission'] = $entity;
    $data['webform'] = $entity
      ->getWebform();
  }
  elseif ($entity instanceof WebformInterface) {
    $data['webform'] = $entity;
  }
  else {
    $data[$entity
      ->getEntityTypeId()] = $entity;
  }
}