function cleaner_cron in Cleaner 8.2
Same name and namespace in other branches
- 8 cleaner.module \cleaner_cron()
- 5 cleaner.module \cleaner_cron()
- 6 cleaner.module \cleaner_cron()
- 7 cleaner.module \cleaner_cron()
Implements hook_cron().
2 string references to 'cleaner_cron'
- CleanerKernelTests::testInitialModuleConfig in tests/
src/ Kernel/ CleanerKernelTests.php - Test the initial config values right after module installation.
- CleanerSettingsForm::buildForm in src/
Form/ CleanerSettingsForm.php - Form constructor.
File
- ./
cleaner.module, line 12 - Basic module file.
Code
function cleaner_cron() {
$config = \Drupal::configFactory()
->getEditable('cleaner.settings');
$request_time = (int) \Drupal::time()
->getRequestTime();
$interval = (int) $config
->get('cleaner_cron');
$last = (int) $config
->get('cleaner_last_cron');
if ($request_time >= $last + $interval) {
// Dispatch the CleanerRunEvent.
\Drupal::service('event_dispatcher')
->dispatch(CleanerRunEvent::CLEANER_RUN, new CleanerRunEvent());
}
$config
->set('cleaner_last_cron', $request_time)
->save();
}