You are here

public static function BusinessRule::getEventTypes in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Entity/BusinessRule.php \Drupal\business_rules\Entity\BusinessRule::getEventTypes()

Return all types of reactions events for business rules.

Return value

array Array of event types.

Overrides BusinessRuleInterface::getEventTypes

2 calls to BusinessRule::getEventTypes()
BusinessRule::getReactsOnLabel in src/Entity/BusinessRule.php
The label of the trigger that will start the rule.
BusinessRuleForm::form in src/Form/BusinessRuleForm.php
Gets the actual form array to be built.

File

src/Entity/BusinessRule.php, line 425

Class

BusinessRule
Defines the Rule entity.

Namespace

Drupal\business_rules\Entity

Code

public static function getEventTypes() {
  $types = [];
  $events = self::$reactsOnManager
    ->getDefinitions();
  uasort($events, function ($a, $b) {
    return $a['label']
      ->render() > $b['label']
      ->render() ? 1 : -1;
  });
  foreach ($events as $event) {
    if (isset($types[$event['group']
      ->render()])) {
      $types[$event['group']
        ->render()] += [
        $event['id'] => $event['label'],
      ];
    }
    else {
      $types[$event['group']
        ->render()] = [
        $event['id'] => $event['label'],
      ];
    }
  }
  ksort($types);
  return $types;
}