SqlSanitizeCommands.php in URLs queuer 8
File
src/Commands/SqlSanitizeCommands.php
View source
<?php
namespace Drupal\purge_queuer_url\Commands;
use Consolidation\AnnotatedCommand\CommandData;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\purge_queuer_url\TrafficRegistryInterface;
use Drush\Commands\DrushCommands;
use Drush\Drupal\Commands\sql\SanitizePluginInterface;
use Drush\Drush;
use Symfony\Component\Console\Input\InputInterface;
class SqlSanitizeCommands extends DrushCommands implements SanitizePluginInterface {
protected $moduleHandler;
protected $registry;
public function __construct(ModuleHandlerInterface $module_handler, TrafficRegistryInterface $registry) {
$this->moduleHandler = $module_handler;
$this->registry = $registry;
}
public function sanitize($result, CommandData $commandData) {
if ($this
->applies()) {
$this->registry
->clear();
}
}
public function messages(&$messages, InputInterface $input) {
if ($this
->applies()) {
$messages[] = dt('Clear Purge URLs queuer traffic history.');
}
return [];
}
protected function applies() {
Drush::bootstrapManager()
->doBootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
return $this->moduleHandler
->moduleExists('purge_queuer_url');
}
}