function _webform_token_get_submission_values in Webform 8.5
Same name and namespace in other branches
- 6.x webform.tokens.inc \_webform_token_get_submission_values()
Get webform submission values.
Parameters
array $options: An array of token options.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
Return value
\Drupal\Component\Render\MarkupInterface|string Webform submission values.
2 calls to _webform_token_get_submission_values()
- webform_tokens in ./
webform.tokens.inc - Implements hook_tokens().
- _webform_token_get_submission_value in ./
webform.tokens.inc - Get webform submission token value.
File
- ./
webform.tokens.inc, line 1065 - Builds placeholder replacement tokens for webforms and submissions.
Code
function _webform_token_get_submission_values(array $options, WebformSubmissionInterface $webform_submission) {
$token = !empty($options['html']) ? '[webform_submission:values:html]' : '[webform_submission:values]';
if (WebformLogicHelper::startRecursionTracking($token) === FALSE) {
return '';
}
$submission_format = !empty($options['html']) ? 'html' : 'text';
/** @var \Drupal\webform\WebformSubmissionViewBuilderInterface $view_builder */
$view_builder = \Drupal::entityTypeManager()
->getViewBuilder('webform_submission');
$form_elements = $webform_submission
->getWebform()
->getElementsInitialized();
$token_value = $view_builder
->buildElements($form_elements, $webform_submission, $options, $submission_format);
// Note, tokens can't include CSS and JS libraries since they can be
// included in an email.
$value = \Drupal::service('renderer')
->renderPlain($token_value);
if (WebformLogicHelper::stopRecursionTracking($token) === FALSE) {
return '';
}
return $value;
}