public function SiteAlertCommands::delete in Site Alert 8
Delete site alert(s) matching the label.
@command site-alert:delete
@usage drush site-alert:delete "label" Delete any site alerts that are active and have the label of "label".
Parameters
string $label: The label of the site alert(s) to delete.
File
- src/
Commands/ SiteAlertCommands.php, line 115
Class
- SiteAlertCommands
- A Drush command file for the Site Alert module.
Namespace
Drupal\site_alert\CommandsCode
public function delete(string $label) : int {
if (!$this
->io()
->confirm(dt("Are you sure you want to delete the site alert labeled '@label'?", [
'@label' => $label,
]))) {
$this
->logger()
->warning('Operation cancelled by user');
return self::EXIT_FAILURE;
}
try {
$count = $this->cli
->delete($label);
} catch (\Exception $e) {
$this
->logger()
->error($e
->getMessage());
return self::EXIT_FAILURE;
}
$vars = [
'@name' => 'site alerts',
'@count' => $count,
'@label' => $label,
];
if ($count >= 1) {
$this
->logger()
->success((string) dt("Deleted @count @name labelled '@label'.", $vars));
}
else {
$this
->logger()
->notice((string) dt("Found no @name with label '@label' to delete.", $vars));
}
return self::EXIT_SUCCESS;
}