You are here

public function SerialLauncher::lock in Ultimate Cron 8.2

Lock job.

Parameters

\Drupal\ultimate_cron\CronJobInterface $job: The job to lock.

Return value

string|FALSE Lock ID or FALSE.

Overrides LauncherInterface::lock

File

src/Plugin/ultimate_cron/Launcher/SerialLauncher.php, line 139

Class

SerialLauncher
Ultimate Cron launcher plugin class.

Namespace

Drupal\ultimate_cron\Plugin\ultimate_cron\Launcher

Code

public function lock(CronJobInterface $job) {
  if (array_key_exists('timeouts', $this->configuration)) {
    $timeout = $this->configuration['timeouts']['lock_timeout'];
  }
  else {
    $timeout = 0;
  }
  $lock = \Drupal::service('ultimate_cron.lock');
  if ($lock_id = $lock
    ->lock($job
    ->id(), $timeout)) {
    $lock_id = $this
      ->getPluginId() . '-' . $lock_id;
    return $lock_id;
  }
  return FALSE;
}