public function WebformSanitizeSubmissionsCommands::sanitize in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Commands/WebformSanitizeSubmissionsCommands.php \Drupal\webform\Commands\WebformSanitizeSubmissionsCommands::sanitize()
Sanitize webform submissions from the DB.
@hook post-command sql-sanitize
File
- src/
Commands/ WebformSanitizeSubmissionsCommands.php, line 65
Class
- WebformSanitizeSubmissionsCommands
- Drush sql-sanitize plugin for sanitizing (truncating) webform submissions.
Namespace
Drupal\webform\CommandsCode
public function sanitize($result, CommandData $command_data) {
$options = $command_data
->options();
if ($this
->isEnabled($options['sanitize-webform-submissions'])) {
$this->database
->truncate('webform_submission')
->execute();
$this->database
->truncate('webform_submission_data')
->execute();
if ($this->moduleHandler
->moduleExists('webform_submission_log')) {
$this->database
->truncate('webform_submission_log')
->execute();
}
$this->entityTypeManager
->getStorage('webform_submission')
->resetCache();
$this
->logger()
->notice(dt('Webform submission tables truncated.'));
}
}