You are here

private function RadioactivityProcessor::hasReachedGranularityThreshold in Radioactivity 8.3

Same name and namespace in other branches
  1. 4.0.x src/RadioactivityProcessor.php \Drupal\radioactivity\RadioactivityProcessor::hasReachedGranularityThreshold()

Determines if the field has reached the next granularity threshold.

For some profiles profile, we only calculate the decay when 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.

1 call to RadioactivityProcessor::hasReachedGranularityThreshold()
RadioactivityProcessor::processDecay in src/RadioactivityProcessor.php
Apply decay to entities.

File

src/RadioactivityProcessor.php, line 145

Class

RadioactivityProcessor
Class RadioactivityProcessor.

Namespace

Drupal\radioactivity

Code

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;
}