You are here

protected function ScheduleEmailWebformHandler::unscheduleMessage in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php \Drupal\webform_scheduled_email\Plugin\WebformHandler\ScheduleEmailWebformHandler::unscheduleMessage()

Unschedule the sending of an email.

Parameters

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

2 calls to ScheduleEmailWebformHandler::unscheduleMessage()
ScheduleEmailWebformHandler::postDelete in modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
Acts on deleted a webform submission before the delete hook is invoked.
ScheduleEmailWebformHandler::postSave in modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
Acts on a saved webform submission before the insert or update hook is invoked.

File

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

Class

ScheduleEmailWebformHandler
Schedules a webform submission's email.

Namespace

Drupal\webform_scheduled_email\Plugin\WebformHandler

Code

protected function unscheduleMessage(WebformSubmissionInterface $webform_submission) {

  /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
  $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
  if ($webform_scheduled_email_manager
    ->hasScheduledEmail($webform_submission, $this
    ->getHandlerId())) {
    $webform_scheduled_email_manager
      ->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);
    }
  }
}