You are here

public static function CronSignal::get in Ultimate Cron 8.2

Get and claim signal.

Parameters

string $name: The name of the job.

string $signal: The name of the signal.

Return value

string The signal if any. If a signal is found, it is "claimed" and therefore cannot be claimed again.

File

src/CronSignal.php, line 40

Class

CronSignal

Namespace

Drupal\ultimate_cron

Code

public static function get($name, $signal) {
  $database = \Drupal::service('ultimate_cron.database_factory');
  $claimed = $database
    ->update('ultimate_cron_signal')
    ->fields(array(
    'claimed' => 1,
  ))
    ->condition('job_name', $name)
    ->condition('signal_name', $signal)
    ->condition('claimed', 0)
    ->execute();
  if ($claimed) {
    $database
      ->delete('ultimate_cron_signal')
      ->condition('job_name', $name)
      ->condition('signal_name', $signal)
      ->condition('claimed', 1)
      ->execute();
  }
  return $claimed;
}