public function EventComponentResolver::getMultiple in Rules 8.3
Gets multiple components.
Parameters
string[] $ids: The list of IDs of the components to get.
Return value
\Drupal\rules\Engine\RulesComponent[] The array of components that could be resolved, keyed by ID.
Overrides RulesComponentResolverInterface::getMultiple
File
- src/
ComponentResolver/ EventComponentResolver.php, line 45
Class
- EventComponentResolver
- Resolves components that hold all reaction rules for a given event.
Namespace
Drupal\rules\ComponentResolverCode
public function getMultiple(array $event_ids) {
// @todo Improve this by adding a custom expression plugin that clones
// the state after each rule, such that added variables added by one rule
// are not interfering with the variables of another rule.
$results = [];
foreach ($event_ids as $event_id) {
$action_set = $this->expressionManager
->createActionSet();
// Only load active reaction rules - inactive (disabled) Rules should
// not be executed, so we shouldn't even load them.
$configs = $this->entityStorage
->loadByProperties([
'events.*.event_name' => $event_id,
'status' => TRUE,
]);
if ($configs) {
// We should only produce $results if there are loaded reaction rules.
foreach ($configs as $config) {
$action_set
->addExpressionObject($config
->getExpression());
}
$results[$event_id] = RulesComponent::create($action_set);
}
}
return $results;
}