JobSchedulerQueue.php in Job Scheduler 8.2
File
src/Plugin/QueueWorker/JobSchedulerQueue.php
View source
<?php
namespace Drupal\job_scheduler\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
class JobSchedulerQueue extends QueueWorkerBase {
protected $scheduler;
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->scheduler = \Drupal::service('job_scheduler.manager');
}
public function processItem($job) {
$scheduler = $this->scheduler;
try {
$scheduler
->execute($job);
} catch (\Exception $e) {
watchdog_exception('job_scheduler', $e);
$scheduler
->remove($job);
}
}
}
Classes
Name |
Description |
JobSchedulerQueue |
Providing our own worker has the advantage that we can reschedule the job or
take care of cleanup. Note that as we run the execute() action, the job won't
be queued again this time. |