private function RadioactivityProcessor::hasReachedGranularityThreshold in Radioactivity 4.0.x
Same name and namespace in other branches
- 8.3 src/RadioactivityProcessor.php \Drupal\radioactivity\RadioactivityProcessor::hasReachedGranularityThreshold()
Determines if the field has reached the next granularity threshold.
For linear and decay profile types, we calculate the decay after x seconds have passed since the last cron run. The number of seconds is stored in 'granularity' field setting.
Parameters
\Drupal\field\FieldStorageConfigInterface $fieldConfig: Configuration of the field to be checked.
Return value
bool True if the threshold was reached.
2 calls to RadioactivityProcessor::hasReachedGranularityThreshold()
- RadioactivityProcessor::processRadioactivityDecay in src/
RadioactivityProcessor.php - Process decay of 'radioactivity' type field.
- RadioactivityProcessor::processRadioactivityReferenceDecay in src/
RadioactivityProcessor.php - Process decay of 'radioactivity_reference' type field.
File
- src/
RadioactivityProcessor.php, line 225
Class
- RadioactivityProcessor
- Processes Radioactivity incidents and and energy decay.
Namespace
Drupal\radioactivityCode
private function hasReachedGranularityThreshold(FieldStorageConfigInterface $fieldConfig) {
$granularity = $fieldConfig
->getSetting('granularity');
if ($granularity == 0) {
return TRUE;
}
$lastCronTimestamp = $this->state
->get(self::LAST_PROCESSED_STATE_KEY, 0);
$threshold = $lastCronTimestamp - $lastCronTimestamp % $granularity + $granularity;
return $this->requestTime >= $threshold;
}