class CleanerSessionController in Cleaner 8
Class CleanerSessionController.
@package Drupal\cleaner\Controller
Hierarchy
- class \Drupal\cleaner\Controller\CleanerSessionController implements CleanerControllersInterface
Expanded class hierarchy of CleanerSessionController
1 string reference to 'CleanerSessionController'
1 service uses CleanerSessionController
File
- src/
Controller/ CleanerSessionController.php, line 12
Namespace
Drupal\cleaner\ControllerView source
class CleanerSessionController implements CleanerControllersInterface {
/**
* Configuration name.
*
* @var string
*/
public static $configName = 'cleaner_clean_sessions';
/**
* {@inheritdoc}
*/
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.');
}
}
}
/**
* Get the sessions expiration time.
*
* @return int
* Expiration timestamp.
*/
private static function getExpirationTime() {
return (int) (REQUEST_TIME - session_get_cookie_params()['lifetime']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CleanerSessionController:: |
public static | property | Configuration name. | |
CleanerSessionController:: |
public | function |
Perform the operation. Overrides CleanerControllersInterface:: |
|
CleanerSessionController:: |
private static | function | Get the sessions expiration time. |