class MailgunSanitizeCommands in Mailgun 8
Drush sql-sanitize plugin for sanitizing data in the Mailgun queue.
Hierarchy
- class \Drupal\mailgun\Commands\MailgunSanitizeCommands extends \Drush\Commands\DrushCommands implements \Drush\Drupal\Commands\sql\SanitizePluginInterface
Expanded class hierarchy of MailgunSanitizeCommands
See also
\Drush\Drupal\Commands\sql\SanitizeSessionsCommands
1 string reference to 'MailgunSanitizeCommands'
1 service uses MailgunSanitizeCommands
File
- src/
Commands/ MailgunSanitizeCommands.php, line 16
Namespace
Drupal\mailgun\CommandsView source
class MailgunSanitizeCommands extends DrushCommands implements SanitizePluginInterface {
/**
* The Mailgun Queue Worker.
*
* @var \Drupal\Core\Queue\QueueInterface
*/
protected $mailgunQueueWorker;
/**
* MailgunSanitizeCommands constructor.
*
* @param \Drupal\Core\Queue\QueueFactory $queueFactory
* The queue factory.
*/
public function __construct(QueueFactory $queueFactory) {
parent::__construct();
$this->mailgunQueueWorker = $queueFactory
->get('mailgun_send_mail');
}
/**
* Adds 'sanitize-mailgun-queue' to the options list.
*
* By default, the queue will be emptied. Please add the following option to
* prevent that '--sanitize-mailgun-queue=no'.
*
* @hook option sql-sanitize
* @option sanitize-mailgun-queue
*/
public function options($options = [
'sanitize-mailgun-queue' => NULL,
]) {
}
/**
* Removes all items from the Mailgun queue.
*
* @hook post-command sql-sanitize
*/
public function sanitize($result, CommandData $command_data) {
$options = $command_data
->options();
if ($this
->applies($options['sanitize-mailgun-queue'])) {
$this->mailgunQueueWorker
->deleteQueue();
$this
->logger()
->success(dt('Mailgun queue emptied.'));
}
}
/**
* Prepares messages.
*
* @hook on-event sql-sanitize-confirms
*/
public function messages(&$messages, InputInterface $input) {
$options = $input
->getOptions();
if ($this
->applies($options['sanitize-mailgun-queue'])) {
$messages[] = dt('Empty Mailgun queue.');
}
}
/**
* Verifies that 'sanitize-mailgun-queue' option is not set to "no".
*
* @return bool
* TRUE if santize realname is enabled.
*/
protected function applies($value) {
return $value !== 'no';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MailgunSanitizeCommands:: |
protected | property | The Mailgun Queue Worker. | |
MailgunSanitizeCommands:: |
protected | function | Verifies that 'sanitize-mailgun-queue' option is not set to "no". | |
MailgunSanitizeCommands:: |
public | function | Prepares messages. | |
MailgunSanitizeCommands:: |
public | function | Adds 'sanitize-mailgun-queue' to the options list. | |
MailgunSanitizeCommands:: |
public | function | Removes all items from the Mailgun queue. | |
MailgunSanitizeCommands:: |
public | function | MailgunSanitizeCommands constructor. |