You are here

protected function EmailWebformHandler::getDefaultConfigurationValues in Webform 8.5

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

Get configuration default values.

Return value

array Configuration default values.

1 call to EmailWebformHandler::getDefaultConfigurationValues()
EmailWebformHandler::getDefaultConfigurationValue in src/Plugin/WebformHandler/EmailWebformHandler.php
Get configuration default value.

File

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

Class

EmailWebformHandler
Emails a webform submission.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

protected function getDefaultConfigurationValues() {
  if (isset($this->defaultValues)) {
    return $this->defaultValues;
  }
  $webform_settings = $this->configFactory
    ->get('webform.settings');
  $site_settings = $this->configFactory
    ->get('system.site');
  $body_format = $this->configuration['html'] ? 'html' : 'text';
  $default_to_mail = $webform_settings
    ->get('mail.default_to_mail') ?: $site_settings
    ->get('mail') ?: ini_get('sendmail_from');
  $default_from_mail = $webform_settings
    ->get('mail.default_from_mail') ?: $site_settings
    ->get('mail') ?: ini_get('sendmail_from');
  $this->defaultValues = [
    'states' => [
      WebformSubmissionInterface::STATE_COMPLETED,
    ],
    'to_mail' => $default_to_mail,
    'to_options' => [],
    'cc_mail' => $default_to_mail,
    'cc_options' => [],
    'bcc_mail' => $default_to_mail,
    'bcc_options' => [],
    'from_mail' => $default_from_mail,
    'from_options' => [],
    'from_name' => $webform_settings
      ->get('mail.default_from_name') ?: $site_settings
      ->get('name'),
    'subject' => $webform_settings
      ->get('mail.default_subject') ?: 'Webform submission from: [webform_submission:source-entity]',
    'body' => $this
      ->getBodyDefaultValues($body_format),
    'reply_to' => $webform_settings
      ->get('mail.default_reply_to') ?: '',
    'return_path' => $webform_settings
      ->get('mail.default_return_path') ?: '',
    'sender_mail' => $webform_settings
      ->get('mail.default_sender_mail') ?: '',
    'sender_name' => $webform_settings
      ->get('mail.default_sender_name') ?: '',
    'theme_name' => '',
  ];
  return $this->defaultValues;
}