You are here

class SqlSanitizeCommands in URLs queuer 8

Sanitize plugin for Drush sql:sanitize which clears the URL registry.

Hierarchy

  • class \Drupal\purge_queuer_url\Commands\SqlSanitizeCommands extends \Drush\Commands\DrushCommands implements \Drush\Drupal\Commands\sql\SanitizePluginInterface

Expanded class hierarchy of SqlSanitizeCommands

1 string reference to 'SqlSanitizeCommands'
drush.services.yml in ./drush.services.yml
drush.services.yml
1 service uses SqlSanitizeCommands
purge_queuer_url.sqlsanitize.commands in ./drush.services.yml
\Drupal\purge_queuer_url\Commands\SqlSanitizeCommands

File

src/Commands/SqlSanitizeCommands.php, line 16

Namespace

Drupal\purge_queuer_url\Commands
View source
class SqlSanitizeCommands extends DrushCommands implements SanitizePluginInterface {

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * The traffic registry with the stored URLs and tags.
   *
   * @var \Drupal\purge_queuer_url\TrafficRegistryInterface
   */
  protected $registry;

  /**
   * Constructs a SqlSanitizeCommands object.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   * @param \Drupal\purge_queuer_url\TrafficRegistryInterface $registry
   *   The traffic registry with the stored URLs and tags.
   */
  public function __construct(ModuleHandlerInterface $module_handler, TrafficRegistryInterface $registry) {
    $this->moduleHandler = $module_handler;
    $this->registry = $registry;
  }

  /**
   * Clear Purge URLs queuer traffic history.
   *
   * @hook post-command sql-sanitize
   *
   * @inheritdoc
   */
  public function sanitize($result, CommandData $commandData) {
    if ($this
      ->applies()) {
      $this->registry
        ->clear();
    }
  }

  /**
   * Return the messages.
   *
   * @hook on-event sql-sanitize-confirms
   *
   * @inheritdoc
   */
  public function messages(&$messages, InputInterface $input) {
    if ($this
      ->applies()) {
      $messages[] = dt('Clear Purge URLs queuer traffic history.');
    }
    return [];
  }

  /**
   * Verify if the module is enabled.
   */
  protected function applies() {
    Drush::bootstrapManager()
      ->doBootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
    return $this->moduleHandler
      ->moduleExists('purge_queuer_url');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SqlSanitizeCommands::$moduleHandler protected property The module handler.
SqlSanitizeCommands::$registry protected property The traffic registry with the stored URLs and tags.
SqlSanitizeCommands::applies protected function Verify if the module is enabled.
SqlSanitizeCommands::messages public function Return the messages.
SqlSanitizeCommands::sanitize public function Clear Purge URLs queuer traffic history.
SqlSanitizeCommands::__construct public function Constructs a SqlSanitizeCommands object.