You are here

public function CleanerWatchdogController::execute in Cleaner 8

Perform the operation.

Overrides CleanerControllersInterface::execute

File

src/Controller/CleanerWatchdogController.php, line 35

Class

CleanerWatchdogController
Class CleanerWatchdogController.

Namespace

Drupal\cleaner\Controller

Code

public function execute() {
  if (\Drupal::config(CLEANER_SETTINGS)
    ->get(self::$configName)) {
    if (self::cleanWatchdog()) {
      static::$logLevel = LogLevel::INFO;
      static::$logMessage = 'Watchdog logs has been successfully cleared.';
    }
    else {
      static::$logLevel = LogLevel::ERROR;
      static::$logMessage = 'Something going wrong - watchdog logs can\'t be cleared.';
    }
    \Drupal::service('cleaner_logger')
      ->log(static::$logLevel, static::$logMessage);
  }
}