You are here

public function CleanerCacheClearEventSubscriber::clearCaches in Cleaner 8.2

Cleaner caches clearing.

File

src/EventSubscriber/CleanerCacheClearEventSubscriber.php, line 93

Class

CleanerCacheClearEventSubscriber
Class CleanerCacheClearEventSubscriber.

Namespace

Drupal\cleaner\EventSubscriber

Code

public function clearCaches() {
  if ($this->config
    ->get('cleaner_clear_cache')) {
    $cleared = 0;

    // First clearing caches for the static caches.
    $this->cacheBackend
      ->deleteAll();

    // Prepare cache tables list.
    $tables = (array) $this
      ->cleanerGetCacheTables();

    // Ensure tables exist.
    if (!empty($tables)) {

      // Clears the cache tables
      // and increments the cleared entries count.
      $cleared += (int) $this
        ->performClearing($tables);
    }
    $this
      ->writeToLog($cleared);
  }
}