cleaner.module in Cleaner 8
Same filename and directory in other branches
Allows the admin to set a schedule for clearing caches and other stuff.
File
cleaner.moduleView source
<?php
/**
* @file
* Allows the admin to set a schedule for clearing caches and other stuff.
*/
define('CLEANER_SETTINGS', 'cleaner.settings');
/**
* Implements hook_cron().
*/
function cleaner_cron() {
$config = \Drupal::config(CLEANER_SETTINGS);
$interval = (int) $config
->get('cleaner_cron');
$last = (int) $config
->get('cleaner_last_cron');
if (REQUEST_TIME >= $last + $interval) {
\Drupal::moduleHandler()
->invokeAll('cleaner_run');
}
\Drupal::configFactory()
->getEditable(CLEANER_SETTINGS)
->set('cleaner_last_cron', REQUEST_TIME)
->save();
}
/**
* Implements hook_cleaner_run().
*
* This hook run all actions, which has been configured via admin settings page.
*/
function cleaner_cleaner_run() {
\Drupal::service('cleaner')
->run();
}
Functions
Name | Description |
---|---|
cleaner_cleaner_run | Implements hook_cleaner_run(). |
cleaner_cron | Implements hook_cron(). |
Constants
Name | Description |
---|---|
CLEANER_SETTINGS | @file Allows the admin to set a schedule for clearing caches and other stuff. |