You are here

public static function UltimateCronSignal::get in Ultimate Cron 7.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

./ultimate_cron.signal.inc, line 45
File containing functions for Ultimate Cron signal handling.

Class

UltimateCronSignal
Class for handling Ultimate Cron signals.

Code

public static function get($name, $signal) {
  $target = _ultimate_cron_get_transactional_safe_connection();
  $claimed = db_update('ultimate_cron_signal', array(
    'target' => $target,
  ))
    ->fields(array(
    'claimed' => 1,
  ))
    ->condition('job_name', $name)
    ->condition('signal_name', $signal)
    ->condition('claimed', 0)
    ->execute();
  if ($claimed) {
    db_delete('ultimate_cron_signal', array(
      'target' => $target,
    ))
      ->condition('job_name', $name)
      ->condition('signal_name', $signal)
      ->condition('claimed', 1)
      ->execute();
  }
  return $claimed;
}