class UltimateCron in Ultimate Cron 8.2
Same name in this branch
- 8.2 src/UltimateCron.php \Drupal\ultimate_cron\UltimateCron
- 8.2 src/ProxyClass/UltimateCron.php \Drupal\ultimate_cron\ProxyClass\UltimateCron
The Ultimate Cron service.
Hierarchy
- class \Drupal\Core\Cron implements CronInterface
- class \Drupal\ultimate_cron\UltimateCron
Expanded class hierarchy of UltimateCron
File
- src/
UltimateCron.php, line 19
Namespace
Drupal\ultimate_cronView source
class UltimateCron extends Cron {
/**
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Sets the config factory for ultimate cron service.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*/
public function setConfigFactory(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public function run() {
// Load the cron jobs in the right order.
$job_ids = \Drupal::entityQuery('ultimate_cron_job')
->condition('status', TRUE)
->sort('weight', 'ASC')
->execute();
$launcher_jobs = array();
foreach (CronJob::loadMultiple($job_ids) as $job) {
/* @var \Drupal\Core\Plugin\DefaultPluginManager $manager */
$manager = \Drupal::service('plugin.manager.ultimate_cron.' . 'launcher');
$launcher = $manager
->createInstance($job
->getLauncherId());
$launcher_definition = $launcher
->getPluginDefinition();
if (!isset($launchers) || in_array($launcher
->getPluginId(), $launchers)) {
$launcher_jobs[$launcher_definition['id']]['launcher'] = $launcher;
$launcher_jobs[$launcher_definition['id']]['sort'] = array(
$launcher_definition['weight'],
);
$launcher_jobs[$launcher_definition['id']]['jobs'][$job
->id()] = $job;
$launcher_jobs[$launcher_definition['id']]['jobs'][$job
->id()]->sort = array(
$job
->loadLatestLogEntry()->start_time,
);
}
}
foreach ($launcher_jobs as $name => $launcher_job) {
$launcher_job['launcher']
->launchJobs($launcher_job['jobs']);
}
// Run standard queue processing if our own handling is disabled.
if (!$this->configFactory
->get('ultimate_cron.settings')
->get('queue.enabled')) {
$this
->processQueues();
}
$this
->setCronLastTime();
return TRUE;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Cron:: |
protected | property | The account switcher service. | |
Cron:: |
protected | property | The lock service. | |
Cron:: |
protected | property | A logger instance. | |
Cron:: |
protected | property | The module handler service. | |
Cron:: |
protected | property | The queue service. | |
Cron:: |
protected | property | The queue plugin manager. | |
Cron:: |
protected | property | The state service. | |
Cron:: |
protected | property | The time service. | |
Cron:: |
protected | function | Invokes any cron handlers implementing hook_cron. | |
Cron:: |
protected | function | Processes cron queues. | |
Cron:: |
protected | function | Records and logs the request time for this cron invocation. | |
Cron:: |
public | function | Constructs a cron object. | |
UltimateCron:: |
protected | property | ||
UltimateCron:: |
public | function |
Executes a cron run. Overrides Cron:: |
|
UltimateCron:: |
public | function | Sets the config factory for ultimate cron service. |