You are here

public function EmailWebformHandler::getSummary in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformHandler/EmailWebformHandler.php \Drupal\webform\Plugin\WebformHandler\EmailWebformHandler::getSummary()

Returns a render array summarizing the configuration of the webform handler.

Return value

array A render array.

Overrides WebformHandlerBase::getSummary

1 call to EmailWebformHandler::getSummary()
ScheduleEmailWebformHandler::getSummary in modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
Returns a render array summarizing the configuration of the webform handler.
1 method overrides EmailWebformHandler::getSummary()
ScheduleEmailWebformHandler::getSummary in modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
Returns a render array summarizing the configuration of the webform handler.

File

src/Plugin/WebformHandler/EmailWebformHandler.php, line 176

Class

EmailWebformHandler
Emails a webform submission.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

public function getSummary() {
  $settings = $this
    ->getEmailConfiguration();

  // Simplify the [webform_submission:values:.*] tokens.
  array_walk($settings, function (&$value, $key) {
    if (is_string($value)) {
      $value = preg_replace('/\\[webform:([^:]+)\\]/', '[\\1]', $value);
      $value = preg_replace('/\\[webform_role:([^:]+)\\]/', '[\\1]', $value);
      $value = preg_replace('/\\[webform_access:type:([^:]+)\\]/', '[\\1]', $value);
      $value = preg_replace('/\\[webform_group:role:([^:]+)\\]/', '[group:\\1]', $value);
      $value = preg_replace('/\\[webform_group:owner:mail\\]/', '[group:owner]', $value);
      $value = preg_replace('/\\[webform_submission:(?:node|source_entity|values):([^]]+)\\]/', '[\\1]', $value);
      $value = preg_replace('/\\[webform_submission:([^]]+)\\]/', '[\\1]', $value);
      $value = preg_replace('/(:raw|:value)(:html)?\\]/', ']', $value);
    }
  });

  // Set state.
  $states = [
    WebformSubmissionInterface::STATE_DRAFT_CREATED => $this
      ->t('Draft created'),
    WebformSubmissionInterface::STATE_DRAFT_UPDATED => $this
      ->t('Draft updated'),
    WebformSubmissionInterface::STATE_CONVERTED => $this
      ->t('Converted'),
    WebformSubmissionInterface::STATE_COMPLETED => $this
      ->t('Completed'),
    WebformSubmissionInterface::STATE_UPDATED => $this
      ->t('Updated'),
    WebformSubmissionInterface::STATE_DELETED => $this
      ->t('Deleted'),
  ];
  $settings['states'] = array_intersect_key($states, array_combine($settings['states'], $settings['states']));

  // Set theme name.
  if ($settings['theme_name']) {
    $settings['theme_name'] = $this->themeManager
      ->getThemeName($settings['theme_name']);
  }
  return [
    '#settings' => $settings,
  ] + parent::getSummary();
}