You are here

public function RadioactivityProcessor::processDecay in Radioactivity 4.0.x

Same name and namespace in other branches
  1. 8.3 src/RadioactivityProcessor.php \Drupal\radioactivity\RadioactivityProcessor::processDecay()

Apply decay to entities.

Return value

int The number of decays processed.

Overrides RadioactivityProcessorInterface::processDecay

File

src/RadioactivityProcessor.php, line 103

Class

RadioactivityProcessor
Processes Radioactivity incidents and and energy decay.

Namespace

Drupal\radioactivity

Code

public function processDecay() {
  $raCount = $this
    ->processRadioactivityDecay();
  $raRefCount = $this
    ->processRadioactivityReferenceDecay();

  // If no Radioactivity fields are configured, both counts are false and
  // there is need to report anything.
  if ($raCount === FALSE && $raRefCount === FALSE) {

    // @todo Set watchdog message to suggest disabling the RA module.
    return 0;
  }
  $this->state
    ->set(self::LAST_PROCESSED_STATE_KEY, $this->requestTime);
  $raCount = $raCount ?: 0;
  $raRefCount = $raRefCount ?: 0;
  $resultCount = $raCount + $raRefCount;
  $this->log
    ->notice('Processed @count radioactivity decays.', [
    '@count' => $resultCount,
  ]);
  return $resultCount;
}