You are here

class ScheduleEmailWebformHandler in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php \Drupal\webform_scheduled_email\Plugin\WebformHandler\ScheduleEmailWebformHandler

Schedules a webform submission's email.

Plugin annotation


@WebformHandler(
  id = "scheduled_email",
  label = @Translation("Scheduled email"),
  category = @Translation("Notification"),
  description = @Translation("Sends a webform submission via a scheduled email."),
  cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
  results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
  submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_REQUIRED,
)

Hierarchy

Expanded class hierarchy of ScheduleEmailWebformHandler

2 files declare their use of ScheduleEmailWebformHandler
WebformScheduledEmailCommands.php in modules/webform_scheduled_email/src/Commands/WebformScheduledEmailCommands.php
webform_scheduled_email.drush.inc in modules/webform_scheduled_email/drush/webform_scheduled_email.drush.inc
Webform scheduled email module drush commands.

File

modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php, line 29

Namespace

Drupal\webform_scheduled_email\Plugin\WebformHandler
View source
class ScheduleEmailWebformHandler extends EmailWebformHandler {

  /**
   * The current request.
   *
   * @var null|\Symfony\Component\HttpFoundation\Request
   */
  protected $request;

  /**
   * The webform scheculed email manager.
   *
   * @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface
   */
  protected $scheduledEmailManager;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
    $instance->request = $container
      ->get('request_stack')
      ->getCurrentRequest();
    $instance->scheduledEmailManager = $container
      ->get('webform_scheduled_email.manager');
    return $instance;
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return parent::defaultConfiguration() + [
      'send' => '[date:html_date]',
      'days' => '',
      'unschedule' => FALSE,
      'ignore_past' => FALSE,
      'test_send' => FALSE,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getSummary() {
    $status_messages = [
      WebformScheduledEmailManagerInterface::SUBMISSION_WAITING => [
        'message' => $this
          ->t('waiting to be scheduled.'),
        'type' => 'warning',
      ],
      WebformScheduledEmailManagerInterface::SUBMISSION_QUEUED => [
        'message' => $this
          ->t('queued to be sent.'),
        'type' => 'status',
      ],
      WebformScheduledEmailManagerInterface::SUBMISSION_READY => [
        'message' => $this
          ->t('ready to be sent.'),
        'type' => 'warning',
      ],
    ];
    $cron_link = FALSE;
    $build = [];
    $stats = $this->scheduledEmailManager
      ->stats($this->webform, $this
      ->getHandlerId());
    foreach ($stats as $type => $total) {
      if (empty($total) || !isset($status_messages[$type])) {
        continue;
      }
      $build[$type] = [
        '#type' => 'webform_message',
        '#message_message' => $this
          ->formatPlural($total, '@count email @message', '@count emails @message', [
          '@message' => $status_messages[$type]['message'],
        ]),
        '#message_type' => $status_messages[$type]['type'],
      ];
      if ($status_messages[$type]['type'] === 'warning') {
        $cron_link = TRUE;
      }
    }

    // Display execute cron link.
    if ($cron_link) {
      $build['link'] = [
        '#type' => 'link',
        '#title' => $this
          ->t('Run cron task'),
        '#url' => Url::fromRoute('entity.webform.scheduled_email.cron', [
          'webform' => $this
            ->getWebform()
            ->id(),
          'handler_id' => $this
            ->getHandlerId(),
        ]),
        '#attributes' => [
          'class' => [
            'button',
            'button--small',
          ],
        ],
        '#prefix' => '<p>',
        '#suffix' => '</p>',
      ];
    }
    $summary = parent::getSummary();
    if ($build) {
      $summary['#status'] = [
        '#type' => 'details',
        '#title' => $this
          ->t('Scheduled email status (@total)', [
          '@total' => $stats['total'],
        ]),
        '#help' => FALSE,
        '#description' => $build,
      ];
    }
    return $summary;
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $webform = $this
      ->getWebform();

    // Get options, mail, and text elements as options (text/value).
    $date_element_options = [];
    $elements = $this->webform
      ->getElementsInitializedAndFlattened();
    foreach ($elements as $key => $element) {
      if (isset($element['#type']) && in_array($element['#type'], [
        'date',
        'datetime',
        'datelist',
      ])) {
        $title = isset($element['#title']) ? new FormattableMarkup('@title (@key)', [
          '@title' => $element['#title'],
          '@key' => $key,
        ]) : $key;
        $date_element_options["[webform_submission:values:{$key}:html_date]"] = $title;
      }
    }
    $form['scheduled'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Scheduled email'),
      '#open' => TRUE,
    ];

    // Display warning about submission log.
    if (!$webform
      ->hasSubmissionLog()) {
      $form['scheduled']['warning'] = [
        '#type' => 'webform_message',
        '#message_type' => 'error',
        '#message_message' => $this
          ->t('It is strongly recommended that <a href=":href">submission logging</a> is enable to track scheduled emails.', [
          ':href' => $webform
            ->toUrl('settings-submissions')
            ->toString(),
        ]),
        '#message_close' => TRUE,
        '#message_id' => 'webform_scheduled_email-' . $webform
          ->id(),
        '#message_storage' => WebformMessage::STORAGE_LOCAL,
      ];
    }

    // Send date/time.
    $send_options = [
      '[date:html_date]' => $this
        ->t('Current date'),
      WebformOtherBase::OTHER_OPTION => $this
        ->t('Custom @label…', [
        '@label' => $this->scheduledEmailManager
          ->getDateTypeLabel(),
      ]),
      (string) $this
        ->t('Webform') => [
        '[webform:open:html_date]' => $this
          ->t('Open date'),
        '[webform:close:html_date]' => $this
          ->t('Close date'),
      ],
      (string) $this
        ->t('Webform submission') => [
        '[webform_submission:created:html_date]' => $this
          ->t('Date created'),
        '[webform_submission:completed:html_date]' => $this
          ->t('Date completed'),
        '[webform_submission:changed:html_date]' => $this
          ->t('Date changed'),
      ],
    ];
    if ($date_element_options) {
      $send_options[(string) $this
        ->t('Element')] = $date_element_options;
    }
    $t_args = [
      '@format' => $this->scheduledEmailManager
        ->getDateFormatLabel(),
      '@type' => $this->scheduledEmailManager
        ->getDateTypeLabel(),
    ];
    $form['scheduled']['send'] = [
      '#type' => 'webform_select_other',
      '#title' => $this
        ->t('Send email on'),
      '#options' => $send_options,
      '#other__placeholder' => $this->scheduledEmailManager
        ->getDateFormatLabel(),
      '#other__description' => $this
        ->t('Enter a valid ISO @type (@format) or token which returns a valid ISO @type.', $t_args),
      '#default_value' => $this->configuration['send'],
    ];

    // Send days.
    $days_options = [];
    $days = [
      30,
      14,
      7,
      3,
      2,
      1,
    ];
    foreach ($days as $day) {
      $days_options["-{$day}"] = $this
        ->t('- @day days', [
        '@day' => $day,
      ]);
    }
    $days = array_reverse($days);
    foreach ($days as $day) {
      $days_options[$day] = $this
        ->t('+ @day days', [
        '@day' => $day,
      ]);
    }
    $form['scheduled']['days'] = [
      '#type' => 'webform_select_other',
      '#title' => $this
        ->t('Days'),
      '#title_display' => 'hidden',
      '#empty_option' => $this
        ->t('- None -'),
      '#options' => $days_options,
      '#default_value' => $this->configuration['days'],
      '#other__option_label' => $this
        ->t('Custom number of days…'),
      '#other__type' => 'number',
      '#other__field_suffix' => $this
        ->t('days'),
      '#other__placeholder' => $this
        ->t('Enter +/- days'),
    ];

    // Ignore past.
    $form['scheduled']['ignore_past'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Do not schedule email if the action should be triggered in the past'),
      '#description' => $this
        ->t('You can use this setting to prevent an action to be scheduled if it should have been triggered in the past.'),
      '#default_value' => $this->configuration['ignore_past'],
      '#return_value' => TRUE,
    ];

    // Unschedule.
    $form['scheduled']['unschedule'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Unschedule email when draft or submission is saved'),
      '#description' => $this
        ->t('You can use this setting to unschedule a draft reminder, when submission has been completed.'),
      '#default_value' => $this->configuration['unschedule'],
      '#return_value' => TRUE,
    ];

    // Queue all submissions.
    if ($webform
      ->hasSubmissions()) {
      $form['scheduled']['queue'] = [
        '#type' => 'checkbox',
        '#title' => $this
          ->t('Schedule emails for all existing submissions'),
        '#description' => $this
          ->t('Check schedule emails after submissions have been processed.'),
        '#return_value' => TRUE,
        // Must specify #parents because 'queue' is not a configuration setting.
        // @see \Drupal\webform_scheduled_email\Plugin\WebformHandler\ScheduleEmailWebformHandler::defaultConfiguration
        // @see \Drupal\webform\Plugin\WebformHandlerBase::setSettingsParentsRecursively
        '#parents' => [
          'settings',
          'queue',
        ],
      ];
      $form['scheduled']['queue_message'] = [
        '#type' => 'webform_message',
        '#message_message' => $this
          ->t('Please note all submissions will be rescheduled, including ones that have already received an email from this handler and submissions whose send date is in the past.'),
        '#message_type' => 'warning',
        '#states' => [
          'visible' => [
            ':input[name="settings[queue]"]' => [
              'checked' => TRUE,
            ],
          ],
        ],
      ];
    }

    // Notes.
    $form['scheduled']['notes'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Please note'),
    ];
    $form['scheduled']['notes']['message'] = [
      '#theme' => 'item_list',
      '#items' => [
        $this
          ->t("Only one email can be scheduled per handler and submission."),
        $this
          ->t('Email will be rescheduled when a draft or submission is updated.'),
        $this
          ->t("Multiple handlers can be used to schedule multiple emails."),
        $this
          ->t('Deleting this handler will unschedule all scheduled emails.'),
        [
          '#markup' => $this
            ->t('Scheduled emails are automatically sent starting at midnight using <a href=":href">cron</a>, which is executed at predefined interval.', [
            ':href' => 'https://www.drupal.org/docs/7/setting-up-cron/overview',
          ]),
        ],
      ],
    ];
    $form['scheduled']['token_tree_link'] = $this
      ->buildTokenTreeElement();
    $form = parent::buildConfigurationForm($form, $form_state);

    // Change 'Send email' to 'Scheduled email'.
    $form['settings']['states']['#title'] = $this
      ->t('Schedule email');

    // Development.
    $form['development']['test_send'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Immediately send email when testing a webform'),
      '#return_value' => TRUE,
      '#default_value' => $this->configuration['test_send'],
    ];
    return $this
      ->setSettingsParents($form);
  }

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::validateConfigurationForm($form, $form_state);
    $values = $form_state
      ->getValues();

    // Cast days string to int.
    $values['days'] = (int) $values['days'];

    // If token skip validation.
    if (!preg_match('/^\\[[^]]+\\]$/', $values['send'])) {
      $date_format = $this->scheduledEmailManager
        ->getDateFormat();

      // Validate custom 'send on' date.
      if (WebformDateHelper::createFromFormat($date_format, $values['send']) === FALSE) {
        $t_args = [
          '%field' => $this
            ->t('Send on'),
          '%format' => $this->scheduledEmailManager
            ->getDateFormatLabel(),
          '@type' => $this->scheduledEmailManager
            ->getDateTypeLabel(),
        ];
        $form_state
          ->setError($form['settings']['scheduled']['send'], $this
          ->t('The %field date is required. Please enter a @type in the format %format.', $t_args));
      }
    }
    $form_state
      ->setValues($values);
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);
    if ($form_state
      ->getValue('queue')) {
      $this->scheduledEmailManager
        ->schedule($this
        ->getWebform(), $this
        ->getHandlerId());
    }
  }

  /**
   * {@inheritdoc}
   */
  public function alterForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

    // Display warning when test email will be sent immediately.
    if ($this->request
      ->isMethod('GET') && $this
      ->getWebform()
      ->isTest() && !empty($this->configuration['test_send'])) {
      $t_args = [
        '%label' => $this
          ->getLabel(),
      ];
      $form['scheduled_email_handler_test_send__' . $this
        ->getHandlerId()] = [
        '#type' => 'webform_message',
        '#message_message' => $this
          ->t('The %label email will be sent immediately upon submission.', $t_args),
        '#message_type' => 'warning',
        '#message_close' => TRUE,
        '#weight' => -100,
      ];
    }
  }

  /**
   * {@inheritdoc}
   */
  public function postSave(WebformSubmissionInterface $webform_submission, $update = TRUE) {
    $state = $webform_submission
      ->getState();
    if (in_array($state, $this->configuration['states'])) {
      $this
        ->scheduleMessage($webform_submission);
    }
    elseif ($this->configuration['unschedule']) {
      $this
        ->unscheduleMessage($webform_submission);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function postDelete(WebformSubmissionInterface $webform_submission) {
    $this
      ->unscheduleMessage($webform_submission);
  }

  /**
   * {@inheritdoc}
   */
  public function updateHandler() {
    $this->scheduledEmailManager
      ->reschedule($this->webform, $this
      ->getHandlerId());
  }

  /**
   * {@inheritdoc}
   */
  public function deleteHandler() {
    $this->scheduledEmailManager
      ->unschedule($this->webform, $this
      ->getHandlerId());
  }

  /**
   * Schedule the sending of an email.
   *
   * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
   *   A webform submission.
   *
   * @return bool|string
   *   The status of scheduled email. FALSE is email was not scheduled.
   */
  protected function scheduleMessage(WebformSubmissionInterface $webform_submission) {
    $t_args = [
      '%submission' => $webform_submission
        ->label(),
      '%handler' => $this
        ->label(),
      '%send' => $this->configuration['send'],
    ];

    // Get message to make sure there is a destination.
    $message = $this
      ->getMessage($webform_submission);

    // Don't send the message if empty (aka To, CC, and BCC is empty).
    if (!$this
      ->hasRecipient($webform_submission, $message)) {
      if ($this->configuration['debug']) {
        $this
          ->messenger()
          ->addWarning($this
          ->t('%submission: Email <b>not sent</b> for %handler handler because a <em>To</em>, <em>CC</em>, or <em>BCC</em> email was not provided.', $t_args));
      }
      return FALSE;
    }

    // When testing send email immediately.
    if ($this
      ->getWebform()
      ->isTest() && !empty($this->configuration['test_send'])) {
      $this
        ->sendMessage($webform_submission, $message);
      return TRUE;
    }

    // Get send date.
    $send_iso_date = $this->scheduledEmailManager
      ->getSendDate($webform_submission, $this->handler_id);
    $t_args['%date'] = $send_iso_date;

    // Log and exit when we are unable to schedule an email due to an invalid
    // date.
    if (!$send_iso_date) {
      if ($this->configuration['debug']) {
        $this
          ->messenger()
          ->addWarning($this
          ->t('%submission: Email <b>not scheduled</b> for %handler handler because %send is not a valid date/token.', $t_args), TRUE);
      }
      $context = $t_args + [
        'link' => $this
          ->getWebform()
          ->toLink($this
          ->t('Edit'), 'handlers')
          ->toString(),
      ];
      $this
        ->getLogger()
        ->warning('%submission: Email <b>not scheduled</b> for %handler handler because %send is not a valid date/token.', $context);
      return FALSE;
    }

    // Finally, schedule the email, which also writes to the submission log
    // and watchdog.
    $status = $this->scheduledEmailManager
      ->schedule($webform_submission, $this
      ->getHandlerId());

    // Debug by displaying schedule message onscreen.
    if ($this->configuration['debug']) {
      $statuses = [
        WebformScheduledEmailManagerInterface::EMAIL_ALREADY_SCHEDULED => $this
          ->t('Already Scheduled'),
        WebformScheduledEmailManagerInterface::EMAIL_SCHEDULED => $this
          ->t('Scheduled'),
        WebformScheduledEmailManagerInterface::EMAIL_RESCHEDULED => $this
          ->t('Rescheduled'),
        WebformScheduledEmailManagerInterface::EMAIL_UNSCHEDULED => $this
          ->t('Unscheduled'),
        WebformScheduledEmailManagerInterface::EMAIL_IGNORED => $this
          ->t('Ignored'),
      ];
      $t_args['@action'] = mb_strtolower($statuses[$status]);
      $this
        ->messenger()
        ->addWarning($this
        ->t('%submission: Email <b>@action</b> by %handler handler to be sent on %date.', $t_args), TRUE);
      $debug_message = $this
        ->buildDebugMessage($webform_submission, $message);
      $debug_message['status'] = [
        '#type' => 'item',
        '#title' => $this
          ->t('Status'),
        '#markup' => $statuses[$status],
        '#wrapper_attributes' => [
          'class' => [
            'container-inline',
          ],
          'style' => 'margin: 0',
        ],
        '#weight' => -10,
      ];
      $debug_message['send'] = [
        '#type' => 'item',
        '#title' => $this
          ->t('Send on'),
        '#markup' => $send_iso_date,
        '#wrapper_attributes' => [
          'class' => [
            'container-inline',
          ],
          'style' => 'margin: 0',
        ],
        '#weight' => -10,
      ];
      $this
        ->messenger()
        ->addWarning($this->renderer
        ->renderPlain($debug_message), TRUE);
    }
    return $status;
  }

  /**
   * Unschedule the sending of an email.
   *
   * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
   *   A webform submission.
   */
  protected function unscheduleMessage(WebformSubmissionInterface $webform_submission) {
    if ($this->scheduledEmailManager
      ->hasScheduledEmail($webform_submission, $this
      ->getHandlerId())) {
      $this->scheduledEmailManager
        ->unschedule($webform_submission, $this
        ->getHandlerId());
      if ($this->configuration['debug']) {
        $t_args = [
          '%submission' => $webform_submission
            ->label(),
          '%handler' => $this
            ->label(),
        ];
        $this
          ->messenger()
          ->addWarning($this
          ->t('%submission: Email <b>unscheduled</b> for %handler handler.', $t_args), TRUE);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
EmailWebformHandler::$configFactory protected property The configuration object factory. Overrides WebformHandlerBase::$configFactory
EmailWebformHandler::$currentUser protected property The current user.
EmailWebformHandler::$defaultValues protected property Cache of default configuration values.
EmailWebformHandler::$elementManager protected property The webform element plugin manager.
EmailWebformHandler::$languageManager protected property The language manager.
EmailWebformHandler::$mailManager protected property A mail manager for sending email.
EmailWebformHandler::$moduleHandler protected property The module handler.
EmailWebformHandler::$themeManager protected property The webform theme manager.
EmailWebformHandler::$tokenManager protected property The webform token manager. Overrides WebformHandlerBase::$tokenManager
EmailWebformHandler::buildAttachments protected function Build attachment to be displayed via debug message and resend form.
EmailWebformHandler::buildDebugMessage protected function Build debug message.
EmailWebformHandler::buildElement protected function Build A select other element for email address and names.
EmailWebformHandler::buildTokenTreeElement protected function Build token tree element. Overrides WebformHandlerBase::buildTokenTreeElement
EmailWebformHandler::DEFAULT_OPTION constant Default option value.
EmailWebformHandler::DEFAULT_VALUE constant Default value. (This is used by the handler's settings.)
EmailWebformHandler::EMPTY_OPTION constant Default option value.
EmailWebformHandler::getBodyDefaultValues protected function Get message body default values, which can be formatted as text or html.
EmailWebformHandler::getDefaultConfigurationValue protected function Get configuration default value.
EmailWebformHandler::getDefaultConfigurationValues protected function Get configuration default values.
EmailWebformHandler::getElementKeyFromToken protected function Get element key from webform token.
EmailWebformHandler::getEmailConfiguration public function Get mail configuration values.
EmailWebformHandler::getMailSystemFormatter protected function Get the Mail System's formatter module name.
EmailWebformHandler::getMessage public function Get a fully populated email for a webform submission. Overrides WebformHandlerMessageInterface::getMessage
EmailWebformHandler::getMessageAttachments protected function Get message file attachments.
EmailWebformHandler::getMessageEmails protected function Get message to, cc, bcc, and from email addresses.
EmailWebformHandler::getMessageSummary public function Build message summary. Overrides WebformHandlerMessageInterface::getMessageSummary
EmailWebformHandler::hasRecipient public function Confirm that a message has a recipient. Overrides WebformHandlerMessageInterface::hasRecipient
EmailWebformHandler::OTHER_OPTION constant Other option value.
EmailWebformHandler::resendMessageForm public function Build resend message webform. Overrides WebformHandlerMessageInterface::resendMessageForm
EmailWebformHandler::sendMessage public function Sends and logs a webform submission message. Overrides WebformHandlerMessageInterface::sendMessage
EmailWebformHandler::supportsAttachments protected function Check that emailing files as attachments is supported.
EmailWebformHandler::supportsHtml protected function Check that HTML emails are supported.
MessengerTrait::$messenger protected property The messenger. 27
MessengerTrait::messenger public function Gets the messenger. 27
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 98
ScheduleEmailWebformHandler::$request protected property The current request.
ScheduleEmailWebformHandler::$scheduledEmailManager protected property The webform scheculed email manager.
ScheduleEmailWebformHandler::alterForm public function Alter webform submission form. Overrides WebformHandlerBase::alterForm
ScheduleEmailWebformHandler::buildConfigurationForm public function Form constructor. Overrides EmailWebformHandler::buildConfigurationForm
ScheduleEmailWebformHandler::create public static function IMPORTANT: Webform handlers are initialized and serialized when they are attached to a webform. Make sure not include any services as a dependency injection that directly connect to the database. This will prevent "LogicException: The database… Overrides EmailWebformHandler::create
ScheduleEmailWebformHandler::defaultConfiguration public function Gets default configuration for this plugin. Overrides EmailWebformHandler::defaultConfiguration
ScheduleEmailWebformHandler::deleteHandler public function Acts on handler after it has been removed. Overrides WebformHandlerBase::deleteHandler
ScheduleEmailWebformHandler::getSummary public function Returns a render array summarizing the configuration of the webform handler. Overrides EmailWebformHandler::getSummary
ScheduleEmailWebformHandler::postDelete public function Acts on deleted a webform submission before the delete hook is invoked. Overrides EmailWebformHandler::postDelete
ScheduleEmailWebformHandler::postSave public function Acts on a saved webform submission before the insert or update hook is invoked. Overrides EmailWebformHandler::postSave
ScheduleEmailWebformHandler::scheduleMessage protected function Schedule the sending of an email.
ScheduleEmailWebformHandler::submitConfigurationForm public function Form submission handler. Overrides EmailWebformHandler::submitConfigurationForm
ScheduleEmailWebformHandler::unscheduleMessage protected function Unschedule the sending of an email.
ScheduleEmailWebformHandler::updateHandler public function Acts on handler after it has been updated. Overrides WebformHandlerBase::updateHandler
ScheduleEmailWebformHandler::validateConfigurationForm public function Form validation handler. Overrides EmailWebformHandler::validateConfigurationForm
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
WebformAjaxElementTrait::buildAjaxElement public function Build an Ajax element.
WebformAjaxElementTrait::buildAjaxElementTrigger public function Build an Ajax element's trigger.
WebformAjaxElementTrait::buildAjaxElementUpdate public function Build an Ajax element's update (submit) button.
WebformAjaxElementTrait::buildAjaxElementWrapper public function Build an Ajax element's wrapper.
WebformAjaxElementTrait::getAjaxElementUpdateClass public function Get Ajax element update class.
WebformAjaxElementTrait::getAjaxElementUpdateName public function Get Ajax element update name.
WebformAjaxElementTrait::getAjaxElementWrapperId public function Get Ajax element wrapper id.
WebformAjaxElementTrait::getAjaxElementWrapperRecursive protected static function Get ajax element wrapper.
WebformAjaxElementTrait::submitAjaxElementCallback public static function Ajax element submit callback. 2
WebformAjaxElementTrait::updateAjaxElementCallback public static function Ajax element update callback.
WebformAjaxElementTrait::validateAjaxElementCallback public static function Ajax element validate callback.
WebformEntityInjectionTrait::getWebform public function Get the webform that this handler is attached to.
WebformEntityInjectionTrait::getWebformSubmission public function Set webform and webform submission entity.
WebformEntityInjectionTrait::resetEntities public function Reset webform and webform submission entity.
WebformEntityInjectionTrait::setEntities public function
WebformEntityInjectionTrait::setWebform public function Set the webform that this is handler is attached to.
WebformEntityInjectionTrait::setWebformSubmission public function Get the webform submission that this handler is handling.
WebformEntityStorageTrait::$entityStorageToTypeMappings protected property An associate array of entity type storage aliases.
WebformEntityStorageTrait::$entityTypeManager protected property The entity type manager. 5
WebformEntityStorageTrait::getEntityStorage protected function Retrieves the entity storage.
WebformEntityStorageTrait::getSubmissionStorage protected function Retrieves the webform submission storage.
WebformEntityStorageTrait::getWebformStorage protected function Retrieves the webform storage.
WebformEntityStorageTrait::__get public function Implements the magic __get() method.
WebformHandlerBase::$conditions protected property The webform handler's conditions.
WebformHandlerBase::$conditionsResultCache protected property The webform handler's conditions result cache.
WebformHandlerBase::$conditionsValidator protected property The webform submission (server-side) conditions (#states) validator.
WebformHandlerBase::$handler_id protected property The webform handler ID.
WebformHandlerBase::$label protected property The webform handler label.
WebformHandlerBase::$loggerFactory protected property The logger factory.
WebformHandlerBase::$notes protected property The webform variant notes.
WebformHandlerBase::$renderer protected property The renderer. 1
WebformHandlerBase::$status protected property The webform handler status.
WebformHandlerBase::$webform protected property The webform. Overrides WebformEntityInjectionTrait::$webform
WebformHandlerBase::$webformSubmission protected property The webform submission. Overrides WebformEntityInjectionTrait::$webformSubmission
WebformHandlerBase::$weight protected property The weight of the webform handler.
WebformHandlerBase::access public function Controls entity operation access to webform submission. Overrides WebformHandlerInterface::access 1
WebformHandlerBase::accessElement public function Controls entity operation access to webform submission element. Overrides WebformHandlerInterface::accessElement 1
WebformHandlerBase::alterElement public function Alter webform element. Overrides WebformHandlerInterface::alterElement 2
WebformHandlerBase::alterElements public function Alter webform submission webform elements. Overrides WebformHandlerInterface::alterElements 2
WebformHandlerBase::applyFormStateToConfiguration protected function Apply submitted form state to configuration.
WebformHandlerBase::cardinality public function Returns the webform handler cardinality settings. Overrides WebformHandlerInterface::cardinality
WebformHandlerBase::checkConditions public function Check handler conditions against a webform submission. Overrides WebformHandlerInterface::checkConditions
WebformHandlerBase::confirmForm public function Confirm webform submission form. Overrides WebformHandlerInterface::confirmForm 2
WebformHandlerBase::createElement public function Acts on a element after it has been created. Overrides WebformHandlerInterface::createElement 2
WebformHandlerBase::createHandler public function Acts on handler after it has been created and added to webform. Overrides WebformHandlerInterface::createHandler 2
WebformHandlerBase::deleteElement public function Acts on a element after it has been deleted. Overrides WebformHandlerInterface::deleteElement 2
WebformHandlerBase::description public function Returns the webform handler description. Overrides WebformHandlerInterface::description
WebformHandlerBase::disable public function Disables the webform handler. Overrides WebformHandlerInterface::disable
WebformHandlerBase::elementTokenValidate protected function Validate form that should have tokens in it.
WebformHandlerBase::enable public function Enables the webform handler. Overrides WebformHandlerInterface::enable
WebformHandlerBase::getConditions public function Returns the conditions the webform handler. Overrides WebformHandlerInterface::getConditions
WebformHandlerBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
WebformHandlerBase::getHandlerId public function Returns the unique ID representing the webform handler. Overrides WebformHandlerInterface::getHandlerId
WebformHandlerBase::getLabel public function Returns the label of the webform handler. Overrides WebformHandlerInterface::getLabel
WebformHandlerBase::getLogger protected function Get webform or webform_submission logger.
WebformHandlerBase::getNotes public function Returns notes of the webform variant. Overrides WebformHandlerInterface::getNotes
WebformHandlerBase::getOffCanvasWidth public function Get configuration form's off-canvas width. Overrides WebformHandlerInterface::getOffCanvasWidth 1
WebformHandlerBase::getStatus public function Returns the status of the webform handler. Overrides WebformHandlerInterface::getStatus
WebformHandlerBase::getWeight public function Returns the weight of the webform handler. Overrides WebformHandlerInterface::getWeight
WebformHandlerBase::hasAnonymousSubmissionTracking public function Determine if the webform handler requires anonymous submission tracking. Overrides WebformHandlerInterface::hasAnonymousSubmissionTracking 1
WebformHandlerBase::isApplicable public function Determine if this handle is applicable to the webform. Overrides WebformHandlerInterface::isApplicable
WebformHandlerBase::isDisabled public function Returns the webform handler disabled indicator. Overrides WebformHandlerInterface::isDisabled
WebformHandlerBase::isEnabled public function Returns the webform handler enabled indicator. Overrides WebformHandlerInterface::isEnabled 1
WebformHandlerBase::isExcluded public function Checks if the handler is excluded via webform.settings. Overrides WebformHandlerInterface::isExcluded
WebformHandlerBase::isSubmissionOptional public function Returns the webform submission is optional indicator. Overrides WebformHandlerInterface::isSubmissionOptional
WebformHandlerBase::isSubmissionRequired public function Returns the webform submission is required indicator. Overrides WebformHandlerInterface::isSubmissionRequired
WebformHandlerBase::label public function Returns the webform handler label. Overrides WebformHandlerInterface::label
WebformHandlerBase::overrideSettings public function Alter/override a webform submission webform settings. Overrides WebformHandlerInterface::overrideSettings 3
WebformHandlerBase::postCreate public function Acts on a webform submission after it is created. Overrides WebformHandlerInterface::postCreate 2
WebformHandlerBase::postLoad public function Acts on loaded webform submission. Overrides WebformHandlerInterface::postLoad 2
WebformHandlerBase::postPurge public function Acts on webform submissions after they are purged. Overrides WebformHandlerInterface::postPurge 1
WebformHandlerBase::preCreate public function Changes the values of an entity before it is created. Overrides WebformHandlerInterface::preCreate 2
WebformHandlerBase::preDelete public function Acts on a webform submission before they are deleted and before hooks are invoked. Overrides WebformHandlerInterface::preDelete 2
WebformHandlerBase::prepareForm public function Acts on an webform submission about to be shown on a webform submission form. Overrides WebformHandlerInterface::prepareForm
WebformHandlerBase::preprocessConfirmation public function Prepares variables for webform confirmation templates. Overrides WebformHandlerInterface::preprocessConfirmation 2
WebformHandlerBase::prePurge public function Acts on webform submissions before they are purged. Overrides WebformHandlerInterface::prePurge 1
WebformHandlerBase::preSave public function Acts on a webform submission before the presave hook is invoked. Overrides WebformHandlerInterface::preSave 2
WebformHandlerBase::replaceTokens protected function Replace tokens in text with no render context.
WebformHandlerBase::setConditions public function Sets the conditions for this webform handler. Overrides WebformHandlerInterface::setConditions
WebformHandlerBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
WebformHandlerBase::setHandlerId public function Sets the id for this webform handler. Overrides WebformHandlerInterface::setHandlerId
WebformHandlerBase::setLabel public function Sets the label for this webform handler. Overrides WebformHandlerInterface::setLabel
WebformHandlerBase::setNotes public function Set notes for this webform variant. Overrides WebformHandlerInterface::setNotes
WebformHandlerBase::setSettingsParents protected function Set configuration settings parents.
WebformHandlerBase::setSettingsParentsRecursively protected function Set configuration settings parents.
WebformHandlerBase::setStatus public function Sets the status for this webform handler. Overrides WebformHandlerInterface::setStatus
WebformHandlerBase::setWeight public function Sets the weight for this webform handler. Overrides WebformHandlerInterface::setWeight
WebformHandlerBase::submitForm public function Submit webform submission form. Overrides WebformHandlerInterface::submitForm 4
WebformHandlerBase::supportsConditions public function Determine if webform handler supports conditions. Overrides WebformHandlerInterface::supportsConditions
WebformHandlerBase::supportsTokens public function Determine if webform handler supports tokens. Overrides WebformHandlerInterface::supportsTokens
WebformHandlerBase::updateElement public function Acts on a element after it has been updated. Overrides WebformHandlerInterface::updateElement 2
WebformHandlerBase::validateForm public function Validate webform submission form. Overrides WebformHandlerInterface::validateForm 2
WebformHandlerInterface::CARDINALITY_SINGLE constant Value indicating a single plugin instances are permitted.
WebformHandlerInterface::CARDINALITY_UNLIMITED constant Value indicating unlimited plugin instances are permitted.
WebformHandlerInterface::RESULTS_IGNORED constant Value indicating webform submissions are not processed (i.e. email or saved) by the handler.
WebformHandlerInterface::RESULTS_PROCESSED constant Value indicating webform submissions are processed (i.e. email or saved) by the handler.
WebformHandlerInterface::SUBMISSION_OPTIONAL constant Value indicating webform submissions do not have to be stored in the database.
WebformHandlerInterface::SUBMISSION_REQUIRED constant Value indicating webform submissions must be stored in the database.
WebformPluginSettingsTrait::getSetting public function
WebformPluginSettingsTrait::getSettings public function
WebformPluginSettingsTrait::setSetting public function
WebformPluginSettingsTrait::setSettings public function