class CronSignal in Ultimate Cron 8.2
Hierarchy
- class \Drupal\ultimate_cron\CronSignal
Expanded class hierarchy of CronSignal
File
- src/
CronSignal.php, line 5
Namespace
Drupal\ultimate_cronView source
class CronSignal {
/**
* Get a signal without claiming it.
*
* @param string $name
* The name of the job.
* @param string $signal
* The name of the signal.
*
* @return string
* The signal if any.
*/
public static function peek($name, $signal) {
$database = \Drupal::service('ultimate_cron.database_factory');
return $database
->select('ultimate_cron_signal', 's')
->fields('s', array(
'job_name',
))
->condition('job_name', $name)
->condition('signal_name', $signal)
->condition('claimed', 0)
->execute()
->fetchField();
}
/**
* Get and claim signal.
*
* @param string $name
* The name of the job.
* @param string $signal
* The name of the signal.
*
* @return string
* The signal if any. If a signal is found, it is "claimed" and therefore
* cannot be claimed again.
*/
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;
}
/**
* Set signal.
*
* @param string $name
* The name of the job.
* @param string $signal
* The name of the signal.
*
* @return boolean
* TRUE if the signal was set.
* @throws \Exception
*/
public static function set($name, $signal) {
$database = \Drupal::service('ultimate_cron.database_factory');
return $database
->merge('ultimate_cron_signal')
->keys(array(
'job_name' => $name,
'signal_name' => $signal,
))
->fields(array(
'claimed' => 0,
))
->execute();
}
/**
* Clear signal.
*
* @param string $name
* The name of the job.
* @param string $signal
* The name of the signal.
*/
public static function clear($name, $signal) {
$database = \Drupal::service('ultimate_cron.database_factory');
$database
->delete('ultimate_cron_signal')
->condition('job_name', $name)
->condition('signal_name', $signal)
->execute();
}
/**
* Clear signals.
*
* @param string $name
* The name of the job.
*/
public static function flush($name) {
$database = \Drupal::service('ultimate_cron.database_factory');
$database
->delete('ultimate_cron_signal')
->condition('job_name', $name)
->execute();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CronSignal:: |
public static | function | Clear signal. | |
CronSignal:: |
public static | function | Clear signals. | |
CronSignal:: |
public static | function | Get and claim signal. | |
CronSignal:: |
public static | function | Get a signal without claiming it. | |
CronSignal:: |
public static | function | Set signal. |