function ReactionRuleConfig::removeEvent

Overrides RulesTriggerableInterface::removeEvent

File

src/Entity/ReactionRuleConfig.php, line 283

Class

ReactionRuleConfig
Reaction rule configuration entity to persistently store configuration.

Namespace

Drupal\rules\Entity

Code

public function removeEvent(string $event_name) {
    $indexed_event_names = array_combine(array_keys($this->events), array_column($this->events, 'event_name'));
    if (($id = array_search($event_name, $indexed_event_names)) !== FALSE) {
        unset($this->events[$id]);
    }
    // Use array_values() to re-index $this->events to ensure that this data
    // structure always has numerical keys that are ordered sequentially,
    // starting with 0. Removing an event might have left a gap in this
    // sequence, which would affect how the configuration was stored.
    $this->events = array_values($this->events);
    return $this;
}