public function WebformScheduledEmailManager::delete in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_scheduled_email/src/WebformScheduledEmailManager.php \Drupal\webform_scheduled_email\WebformScheduledEmailManager::delete()
Delete all scheduled emails associated with a webform or webform submission.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: A webform, webform submission, or source entity.
string|null $handler_id: The webform handler ID.
Overrides WebformScheduledEmailManagerInterface::delete
File
- modules/
webform_scheduled_email/ src/ WebformScheduledEmailManager.php, line 430
Class
- WebformScheduledEmailManager
- Defines the webform scheduled email manager.
Namespace
Drupal\webform_scheduled_emailCode
public function delete(EntityInterface $entity, $handler_id = NULL) {
if ($entity instanceof WebformSubmissionInterface) {
$query = $this->database
->delete('webform_scheduled_email')
->condition('sid', $entity
->id());
if ($handler_id) {
$query
->condition('handler_id', $handler_id);
}
$query
->execute();
}
elseif ($entity instanceof WebformInterface) {
$query = $this->database
->delete('webform_scheduled_email')
->condition('webform_id', $entity
->id());
if ($handler_id) {
$query
->condition('handler_id', $handler_id);
}
$query
->execute();
}
// Since webform and submissions can also be used as a source entity,
// include them in deleting.
$query = $this->database
->delete('webform_scheduled_email')
->condition('entity_type', $entity
->getEntityTypeId())
->condition('entity_id', $entity
->id());
if ($handler_id) {
$query
->condition('handler_id', $handler_id);
}
$query
->execute();
}