function RulesComponent::addContextDefinitionsForEvents

Adds the available event context for the given events.

Parameters

string[] $event_names: The (fully qualified) event names; e.g., as configured for a reaction rule.

Return value

$this

File

src/Engine/RulesComponent.php, line 170

Class

RulesComponent
Handles executable Rules components.

Namespace

Drupal\rules\Engine

Code

public function addContextDefinitionsForEvents(array $event_names) {
    foreach ($event_names as $event_name) {
        // @todo Correctly handle multiple events to intersect available context.
        // @todo Use setter injection for the service.
        $event_definition = \Drupal::service('plugin.manager.rules_event')->getDefinition($event_name);
        foreach ($event_definition['context_definitions'] as $context_name => $context_definition) {
            $this->addContextDefinition($context_name, $context_definition);
        }
    }
    return $this;
}