function ReactionRuleConfig::addEvent

Overrides RulesTriggerableInterface::addEvent

File

src/Entity/ReactionRuleConfig.php, line 256

Class

ReactionRuleConfig
Reaction rule configuration entity to persistently store configuration.

Namespace

Drupal\rules\Entity

Code

public function addEvent(string $event_name, array $configuration = []) {
    if (!$this->hasEvent($event_name)) {
        $event = [
            'event_name' => $event_name,
        ];
        // Only set configuration key if there is configuration.
        // @todo Is this really necessary, as the method parameter has an array
        // type and defaults to the empty array. So $configuration should always
        // be a valid value.
        if (!empty($configuration)) {
            $event['configuration'] = $configuration;
        }
        $this->events[] = $event;
    }
    return $this;
}