You are here

public function EventMeta::trigger in RNG - Events and Registrations 8.2

Same name and namespace in other branches
  1. 8 src/EventMeta.php \Drupal\rng\EventMeta::trigger()
  2. 3.x src/EventMeta.php \Drupal\rng\EventMeta::trigger()

Manually triggers rules for this event.

Parameters

string $trigger: The trigger ID.

array $context: Mixed context.

Overrides EventMetaInterface::trigger

File

src/EventMeta.php, line 423

Class

EventMeta
Meta event wrapper for RNG.

Namespace

Drupal\rng

Code

public function trigger($trigger, $context = []) {
  $context['event'] = $this
    ->getEvent();
  foreach ($this
    ->getRules($trigger) as $rule) {
    if ($rule
      ->evaluateConditions()) {
      foreach ($rule
        ->getActions() as $action) {
        $action
          ->execute($context);
      }
    }
  }
}