You are here

cleaner.module in Cleaner 8

Same filename and directory in other branches
  1. 8.2 cleaner.module
  2. 5 cleaner.module
  3. 6 cleaner.module
  4. 7 cleaner.module

Allows the admin to set a schedule for clearing caches and other stuff.

File

cleaner.module
View 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

Namesort descending Description
cleaner_cleaner_run Implements hook_cleaner_run().
cleaner_cron Implements hook_cron().

Constants

Namesort descending Description
CLEANER_SETTINGS @file Allows the admin to set a schedule for clearing caches and other stuff.