You are here

public function CronJob::lock in Ultimate Cron 8.2

Lock job.

Overrides CronJobInterface::lock

1 call to CronJob::lock()
CronJob::run in src/Entity/CronJob.php
Run job.

File

src/Entity/CronJob.php, line 383

Class

CronJob
Class for handling cron jobs.

Namespace

Drupal\ultimate_cron\Entity

Code

public function lock() {
  $launcher = $this
    ->getPlugin('launcher');
  $lock_id = $launcher
    ->lock($this);
  if (!$lock_id) {
    \Drupal::logger('ultimate_cron')
      ->error('Could not get lock for job @name', array(
      '@name' => $this
        ->id(),
    ));
    return FALSE;
  }
  $this
    ->sendMessage('lock', array(
    'lock_id' => $lock_id,
  ));
  return $lock_id;
}