You are here

protected function MessageListForm::getCommunicationRules in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Form/MessageListForm.php \Drupal\rng\Form\MessageListForm::getCommunicationRules()
  2. 3.x src/Form/MessageListForm.php \Drupal\rng\Form\MessageListForm::getCommunicationRules()

Get a list of rules.

Parameters

\Drupal\Core\Entity\EntityInterface $event: An event entity.

Return value

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

2 calls to MessageListForm::getCommunicationRules()
MessageListForm::buildForm in src/Form/MessageListForm.php
Form constructor.
MessageListForm::submitForm in src/Form/MessageListForm.php
Form submission handler.

File

src/Form/MessageListForm.php, line 73

Class

MessageListForm
Creates message list form.

Namespace

Drupal\rng\Form

Code

protected function getCommunicationRules(EntityInterface $event) {

  // List of communication related action plugin ids.
  $communication_actions = [
    'rng_courier_message',
  ];
  $rules = [];
  $rules_all = $this->eventManager
    ->getMeta($event)
    ->getRules(NULL, FALSE, NULL);
  foreach ($rules_all as $rid => $rule) {
    foreach ($rule
      ->getActions() as $action) {
      $action_id = $action
        ->getPluginId();
      if (in_array($action_id, $communication_actions)) {
        $rules[$rid] = $rule;
        continue 2;
      }
    }
  }
  return $rules;
}