You are here

class SchedulerCommands in Scheduler 8

Same name and namespace in other branches
  1. 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'
drush.services.yml in ./drush.services.yml
drush.services.yml
1 service uses SchedulerCommands
scheduler.commands in ./drush.services.yml
\Drupal\scheduler\Commands\SchedulerCommands

File

src/Commands/SchedulerCommands.php, line 12

Namespace

Drupal\scheduler\Commands
View 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

Namesort descending Modifiers Type Description Overrides
SchedulerCommands::$messenger protected property The Messenger service.
SchedulerCommands::$schedulerManager protected property The Scheduler manager service.
SchedulerCommands::cron public function Lightweight cron to process Scheduler module tasks.
SchedulerCommands::__construct public function SchedulerCommands constructor.