This repository has been archived on 2025-01-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
drupalcampbristol/web/modules/contrib/webform/src/Element/WebformComputedToken.php
2018-11-23 12:29:20 +00:00

27 lines
761 B
PHP

<?php
namespace Drupal\webform\Element;
use Drupal\webform\WebformSubmissionInterface;
/**
* Provides an item to display computed webform submission values using tokens.
*
* @RenderElement("webform_computed_token")
*/
class WebformComputedToken extends WebformComputedBase {
/**
* {@inheritdoc}
*/
public static function processValue(array $element, WebformSubmissionInterface $webform_submission) {
$mode = static::getMode($element);
/** @var \Drupal\webform\WebformTokenManagerInterface $token_manager */
$token_manager = \Drupal::service('webform.token_manager');
// Replace tokens in value.
return $token_manager->replace($element['#value'], $webform_submission, [], ['html' => ($mode == static::MODE_HTML)]);
}
}