class SchedulerCommands in Scheduler 8
Same name and namespace in other branches
- 2.x src/Commands/SchedulerCommands.php \Drupal\scheduler\Commands\SchedulerCommands
Drush 9 Scheduler commands for Drupal Core 8.4+.
Hierarchy
- class \Drupal\scheduler\Commands\SchedulerCommands extends \Drush\Commands\DrushCommands
Expanded class hierarchy of SchedulerCommands
1 string reference to 'SchedulerCommands'
1 service uses SchedulerCommands
File
- src/
Commands/ SchedulerCommands.php, line 12
Namespace
Drupal\scheduler\CommandsView source
class SchedulerCommands extends DrushCommands {
/**
* The Scheduler manager service.
*
* @var \Drupal\scheduler\SchedulerManager
*/
protected $schedulerManager;
/**
* The Messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* SchedulerCommands constructor.
*
* @param \Drupal\scheduler\SchedulerManager $schedulerManager
* Scheduler manager service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* Messenger service.
*/
public function __construct(SchedulerManager $schedulerManager, MessengerInterface $messenger) {
parent::__construct();
$this->schedulerManager = $schedulerManager;
$this->messenger = $messenger;
}
/**
* Lightweight cron to process Scheduler module tasks.
*
* @param array $options
* An associative array of options whose values come from cli, aliases,
* config, etc.
*
* @option nomsg
* to avoid the "cron completed" message being written to the terminal.
* @option nolog
* to overide the site setting and not write 'started' and 'completed'
* messages to the dblog.
*
* @command scheduler:cron
* @aliases sch-cron, scheduler-cron
*/
public function cron(array $options = [
'nomsg' => NULL,
'nolog' => NULL,
]) {
$this->schedulerManager
->runLightweightCron($options);
$options['nomsg'] ? NULL : $this->messenger
->addMessage(dt('Scheduler lightweight cron completed.'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SchedulerCommands:: |
protected | property | The Messenger service. | |
SchedulerCommands:: |
protected | property | The Scheduler manager service. | |
SchedulerCommands:: |
public | function | Lightweight cron to process Scheduler module tasks. | |
SchedulerCommands:: |
public | function | SchedulerCommands constructor. |