You are here

public function UltimateCronCommands::enable in Ultimate Cron 8.2

Enable cron job.

@command cron:enable

@option all Enabled all jobs @usage drush cron-enable node_cron Enable the node_cron job @aliases cre cron-enable

Parameters

string $name: Job to enable.

array $options: Options array.

File

src/Commands/UltimateCronCommands.php, line 320

Class

UltimateCronCommands
Class UltimateCronCommands.

Namespace

Drupal\ultimate_cron\Commands

Code

public function enable($name, array $options = [
  'all' => NULL,
]) {
  if (!$name) {
    if (!$options['all']) {
      throw new \Exception(dt('No job specified?'));
    }

    /** @var \Drupal\ultimate_cron\Entity\CronJob $job */
    foreach (CronJob::loadMultiple() as $job) {
      $job
        ->enable()
        ->save();
    }
    return;
  }
  $job = CronJob::load($name);
  if ($job
    ->enable()
    ->save()) {
    $this->output
      ->writeln(dt('@name enabled', [
      '@name' => $name,
    ]));
  }
}