You are here

class TokenCommands in Token 8

TokenCommands provides the Drush hook implementation for cache clears.

Hierarchy

  • class \Drupal\token\Commands\TokenCommands extends \Drush\Commands\DrushCommands

Expanded class hierarchy of TokenCommands

1 string reference to 'TokenCommands'
drush.services.yml in ./drush.services.yml
drush.services.yml
1 service uses TokenCommands
token.commands in ./drush.services.yml
Drupal\token\Commands\TokenCommands

File

src/Commands/TokenCommands.php, line 11

Namespace

Drupal\token\Commands
View source
class TokenCommands extends DrushCommands {

  /**
   * The module_handler service.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * TokenCommands constructor.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
   *   The module_handler service.
   */
  public function __construct(ModuleHandlerInterface $moduleHandler) {
    $this->moduleHandler = $moduleHandler;
  }

  /**
   * Adds a cache clear option for tokens.
   *
   * @param array $types
   *   The Drush clear types to make available.
   * @param bool $includeBootstrappedTypes
   *   Whether to include types only available in a bootstrapped Drupal or not.
   *
   * @hook on-event cache-clear
   */
  public function cacheClear(array &$types, $includeBootstrappedTypes) {
    if (!$includeBootstrappedTypes || !$this->moduleHandler
      ->moduleExists('token')) {
      return;
    }
    $types['token'] = 'token_clear_cache';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TokenCommands::$moduleHandler protected property The module_handler service.
TokenCommands::cacheClear public function Adds a cache clear option for tokens.
TokenCommands::__construct public function TokenCommands constructor.