class Cron implements CronInterface (View source)

The Drupal core Cron service.

Properties

protected ModuleHandlerInterface $moduleHandler

The module handler service.

protected LockBackendInterface $lock

The lock service.

protected QueueFactory $queueFactory

The queue service.

protected StateInterface $state

The state service.

protected AccountSwitcherInterface $accountSwitcher

The account switcher service.

protected LoggerInterface $logger

A logger instance.

protected QueueWorkerManagerInterface $queueManager

The queue plugin manager.

protected TimeInterface $time

The time service.

Methods

__construct(ModuleHandlerInterface $module_handler, LockBackendInterface $lock, QueueFactory $queue_factory, StateInterface $state, AccountSwitcherInterface $account_switcher, LoggerInterface $logger, QueueWorkerManagerInterface $queue_manager, TimeInterface $time = NULL)

Constructs a cron object.

bool
run()

Executes a cron run.

setCronLastTime()

Records and logs the request time for this cron invocation.

processQueues()

Processes cron queues.

invokeCronHandlers()

Invokes any cron handlers implementing hook_cron.

Details

__construct(ModuleHandlerInterface $module_handler, LockBackendInterface $lock, QueueFactory $queue_factory, StateInterface $state, AccountSwitcherInterface $account_switcher, LoggerInterface $logger, QueueWorkerManagerInterface $queue_manager, TimeInterface $time = NULL)

Constructs a cron object.

Parameters

ModuleHandlerInterface $module_handler

The module handler

LockBackendInterface $lock

The lock service.

QueueFactory $queue_factory

The queue service.

StateInterface $state

The state service.

AccountSwitcherInterface $account_switcher

The account switching service.

LoggerInterface $logger

A logger instance.

QueueWorkerManagerInterface $queue_manager

The queue plugin manager.

TimeInterface $time

The time service.

bool run()

Executes a cron run.

Do not call this function from a test. Use $this->cronRun() instead.

Return Value

bool

TRUE upon success, FALSE otherwise.

protected setCronLastTime()

Records and logs the request time for this cron invocation.

protected processQueues()

Processes cron queues.

protected invokeCronHandlers()

Invokes any cron handlers implementing hook_cron.