You are here

public function UltimateCronCommands::disable in Ultimate Cron 8.2

Disable cron job.

@command cron:disable

@option all Enabled all jobs @usage drush cron-disable node_cron Disable the node_cron job @aliases crd cron-disable

Parameters

string $name: Job to disable.

array $options: Options array.

File

src/Commands/UltimateCronCommands.php, line 353

Class

UltimateCronCommands
Class UltimateCronCommands.

Namespace

Drupal\ultimate_cron\Commands

Code

public function disable($name, array $options = [
  'all' => NULL,
]) {
  if (!$name) {
    if (!$options['all']) {
      throw new \Exception(dt('No job specified?'));
    }
    foreach (CronJob::loadMultiple() as $job) {
      $job
        ->disable()
        ->save();
    }
    return;
  }
  $job = CronJob::load($name);
  if ($job
    ->disable()
    ->save()) {
    $this->output
      ->writeln(dt('@name disabled', [
      '@name' => $name,
    ]));
  }
}