You are here

class CacheCommands in Helper 8

Drush commands for clearing caches.

Hierarchy

  • class \Drupal\helper\Commands\CacheCommands extends \Drush\Commands\DrushCommands

Expanded class hierarchy of CacheCommands

1 string reference to 'CacheCommands'
drush.services.yml in ./drush.services.yml
drush.services.yml
1 service uses CacheCommands
helper.commands.cache in ./drush.services.yml
Drupal\helper\Commands\CacheCommands

File

src/Commands/CacheCommands.php, line 12

Namespace

Drupal\helper\Commands
View source
class CacheCommands extends DrushCommands {

  /**
   * Add additional options to the drush cache:clear command.
   *
   * @hook on-event cache-clear
   */
  public function alterCacheTypes(array &$types, $include_bootstrapped_types) {
    if ($include_bootstrapped_types) {
      $types['libraries'] = [
        $this,
        'clearLibraries',
      ];
      $types['bootstrap'] = [
        $this,
        'clearBootstrap',
      ];
    }
  }

  /**
   * Clears the libraries (and CSS/JS) cache.
   */
  public static function clearLibraries() {
    Cache::invalidateTags([
      'library_info',
    ]);
    DrushCacheCommands::clearCssJs();
  }

  /**
   * Clears the bootstrap cache.
   */
  public static function clearBootstrap() {
    \Drupal::cache('bootstrap')
      ->deleteAll();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheCommands::alterCacheTypes public function Add additional options to the drush cache:clear command.
CacheCommands::clearBootstrap public static function Clears the bootstrap cache.
CacheCommands::clearLibraries public static function Clears the libraries (and CSS/JS) cache.