You are here

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

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

Get all rules for this event.

Parameters

string|null $trigger: The trigger ID for the rule.

bool $defaults: If there are no rules in the database, generate some unsaved rules.

bool $is_active: The status of the rules, or set to NULL for any status.

Return value

\Drupal\rng\Entity\RuleInterface[] An array of rng_rule entities keyed by rule ID.

Overrides EventMetaInterface::getRules

2 calls to EventMeta::getRules()
EventMeta::isDefaultRules in src/EventMeta.php
Determines if this event should use site default rules.
EventMeta::trigger in src/EventMeta.php
Manually triggers rules for this event.

File

src/EventMeta.php, line 341

Class

EventMeta
Meta event wrapper for RNG.

Namespace

Drupal\rng

Code

public function getRules($trigger = NULL, $defaults = FALSE, $is_active = TRUE) {
  $query = $this
    ->buildRuleQuery();
  if ($trigger) {
    $query
      ->condition('trigger_id', $trigger, '=');
  }
  if (isset($is_active)) {
    $query
      ->condition('status', $is_active, '=');
  }
  $rules = $this->entityManager
    ->getStorage('rng_rule')
    ->loadMultiple($query
    ->execute());
  if ($defaults && !$rules) {
    return $this
      ->getDefaultRules($trigger);
  }
  return $rules;
}