public function ScheduledRuleProcessor::processItem in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Plugin/QueueWorker/ScheduledRuleProcessor.php \Drupal\rng\Plugin\QueueWorker\ScheduledRuleProcessor::processItem()
- 3.x src/Plugin/QueueWorker/ScheduledRuleProcessor.php \Drupal\rng\Plugin\QueueWorker\ScheduledRuleProcessor::processItem()
Parameters
integer $data['rule_scheduler_id']: ID of a rule component entity.
Overrides QueueWorkerInterface::processItem
File
- src/
Plugin/ QueueWorker/ ScheduledRuleProcessor.php, line 64
Class
- ScheduledRuleProcessor
- Triggers scheduled rules.
Namespace
Drupal\rng\Plugin\QueueWorkerCode
public function processItem($data) {
if (!isset($data['rule_scheduler_id'])) {
return;
}
if (!($rule_schedule = RuleSchedule::load($data['rule_scheduler_id']))) {
return;
}
$rule_schedule
->incrementAttempts();
$rule_schedule
->save();
if (($component = $rule_schedule
->getComponent()) && ($rule = $component
->getRule())) {
$event = $rule
->getEvent();
$event_meta = $this->eventManager
->getMeta($event);
$context = [
'event' => $event,
'registrations' => $event_meta
->getRegistrations(),
];
foreach ($rule
->getActions() as $action) {
$action
->execute($context);
}
$rule_schedule
->delete();
}
}