class CleanerWatchdogController in Cleaner 8
Class CleanerWatchdogController.
@package Drupal\cleaner\Controller
Hierarchy
- class \Drupal\cleaner\Controller\CleanerWatchdogController implements CleanerControllersInterface
Expanded class hierarchy of CleanerWatchdogController
1 string reference to 'CleanerWatchdogController'
1 service uses CleanerWatchdogController
File
- src/
Controller/ CleanerWatchdogController.php, line 12
Namespace
Drupal\cleaner\ControllerView source
class CleanerWatchdogController implements CleanerControllersInterface {
/**
* Configuration name.
*
* @var string
*/
public static $configName = 'cleaner_empty_watchdog';
/**
* Watchdog log level.
*
* @type string
*/
protected static $logLevel;
/**
* Watchdog log message.
*
* @type string
*/
protected static $logMessage;
/**
* {@inheritdoc}
*/
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);
}
}
/**
* Perform clearing database table - "watchdog".
*
* @return bool
* TRUE on success, FALSE otherwise.
*/
private static function cleanWatchdog() {
if (!\Drupal::database()
->schema()
->tableExists('watchdog')) {
return FALSE;
}
return (bool) \Drupal::database()
->query('TRUNCATE {watchdog}')
->execute();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CleanerWatchdogController:: |
public static | property | Configuration name. | |
CleanerWatchdogController:: |
protected static | property | Watchdog log level. | |
CleanerWatchdogController:: |
protected static | property | Watchdog log message. | |
CleanerWatchdogController:: |
private static | function | Perform clearing database table - "watchdog". | |
CleanerWatchdogController:: |
public | function |
Perform the operation. Overrides CleanerControllersInterface:: |