Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AutomatedCron.php

function AutomatedCron::onTerminate

Run the automated cron if enabled.

Parameters

\Symfony\Component\HttpKernel\Event\TerminateEvent $event: The Event to process.

File

core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php, line 60

Class

AutomatedCron
A subscriber running cron after a response is sent.

Namespace

Drupal\automated_cron\EventSubscriber

Code

public function onTerminate(TerminateEvent $event) {
    $interval = $this->config
        ->get('interval');
    if ($interval > 0) {
        $cron_next = $this->state
            ->get('system.cron_last', 0) + $interval;
        if ((int) $event->getRequest()->server
            ->get('REQUEST_TIME') > $cron_next) {
            $this->cron
                ->run();
        }
    }
}
RSS feed
Powered by Drupal