You are here

public function CleanerSessionController::execute in Cleaner 8

Perform the operation.

Overrides CleanerControllersInterface::execute

File

src/Controller/CleanerSessionController.php, line 23

Class

CleanerSessionController
Class CleanerSessionController.

Namespace

Drupal\cleaner\Controller

Code

public function execute() {
  if (\Drupal::config(CLEANER_SETTINGS)
    ->get(self::$configName)) {
    $count = \Drupal::database()
      ->delete('sessions')
      ->condition('timestamp', self::getExpirationTime(), '<')
      ->execute();
    if ($count) {
      \Drupal::service('cleaner_logger')
        ->log(LogLevel::INFO, 'Old sessions cleared.');
    }
  }
}