You are here

protected function CleanerCacheClearEventSubscriber::performClearing in Cleaner 8.2

Perform caches clearing work.

Parameters

array $tables: Table names array.

Return value

int Amount of cleared tables.

1 call to CleanerCacheClearEventSubscriber::performClearing()
CleanerCacheClearEventSubscriber::clearCaches in src/EventSubscriber/CleanerCacheClearEventSubscriber.php
Cleaner caches clearing.

File

src/EventSubscriber/CleanerCacheClearEventSubscriber.php, line 119

Class

CleanerCacheClearEventSubscriber
Class CleanerCacheClearEventSubscriber.

Namespace

Drupal\cleaner\EventSubscriber

Code

protected function performClearing(array $tables) {
  $cleared = 0;
  foreach ($tables as $table) {
    if (!$this->database
      ->schema()
      ->tableExists($table)) {
      continue;
    }
    if ($this->database
      ->query("TRUNCATE {$table}")
      ->execute()) {
      $cleared++;
    }
  }
  return $cleared;
}