class ScheduledRuleProcessor 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
- 3.x src/Plugin/QueueWorker/ScheduledRuleProcessor.php \Drupal\rng\Plugin\QueueWorker\ScheduledRuleProcessor
Triggers scheduled rules.
Plugin annotation
@QueueWorker(
id = "rng_rule_scheduler",
title = @Translation("Scheduled rule processor"),
cron = {"time" = 60}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\rng\Plugin\QueueWorker\ScheduledRuleProcessor implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of ScheduledRuleProcessor
File
- src/
Plugin/ QueueWorker/ ScheduledRuleProcessor.php, line 20
Namespace
Drupal\rng\Plugin\QueueWorkerView source
class ScheduledRuleProcessor extends QueueWorkerBase implements ContainerFactoryPluginInterface {
/**
* The RNG event manager.
*
* @var \Drupal\rng\EventManagerInterface
*/
protected $eventManager;
/**
* Constructs a ScheduledRuleProcessor object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\rng\EventManagerInterface $event_manager
* The RNG event manager.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EventManagerInterface $event_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->eventManager = $event_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('rng.event_manager'));
}
/**
* {@inheritdoc}
*
* @param integer $data['rule_scheduler_id']
* ID of a rule component entity.
*/
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();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
ScheduledRuleProcessor:: |
protected | property | The RNG event manager. | |
ScheduledRuleProcessor:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
ScheduledRuleProcessor:: |
public | function |
Overrides QueueWorkerInterface:: |
|
ScheduledRuleProcessor:: |
public | function |
Constructs a ScheduledRuleProcessor object. Overrides PluginBase:: |