public static function BusinessRulesListener::getSubscribedEvents in Business Rules 8
Same name and namespace in other branches
- 2.x src/EventSubscriber/BusinessRulesListener.php \Drupal\business_rules\EventSubscriber\BusinessRulesListener::getSubscribedEvents()
File
- src/EventSubscriber/BusinessRulesListener.php, line 117
Class
- BusinessRulesListener
- Class BusinessRulesListener.
Namespace
Drupal\business_rules\EventSubscriber
Code
public static function getSubscribedEvents() {
$return['business_rules.item_pos_delete'] = 'itemPosDelete';
$return[KernelEvents::TERMINATE][] = [
'onTerminate',
100,
];
if (!\Drupal::hasService('state')) {
return self::$staticEvents;
}
if (!\Drupal::hasContainer() || !\Drupal::hasService('plugin.manager.business_rules.reacts_on')) {
$query = Database::getConnection()
->query('SELECT value FROM {key_value} WHERE collection = :collection AND name = :name', [
':collection' => 'state',
':name' => 'system.module.files',
])
->fetchCol();
$modules = [];
if (isset($query[0])) {
$modules = unserialize($query[0]);
}
foreach ($modules as $name => $module) {
$arr = explode('/', $module);
unset($arr[count($arr) - 1]);
$path = implode('/', $arr);
if ($arr[0] != 'core') {
$root_namespaces["Drupal\\{$name}"] = "{$path}/src";
}
}
$root_namespaces['_serviceId'] = 'container.namespaces';
$root_namespaces = new \ArrayIterator($root_namespaces);
$annotation = new AnnotatedClassDiscovery('/Plugin/BusinessRulesReactsOn', $root_namespaces, 'Drupal\\business_rules\\Annotation\\BusinessRulesReactsOn');
$eventsDefinitions = $annotation
->getDefinitions();
}
else {
$container = \Drupal::getContainer();
$reactionEvents = $container
->get('plugin.manager.business_rules.reacts_on');
$eventsDefinitions = $reactionEvents
->getDefinitions();
}
foreach ($eventsDefinitions as $event) {
$return[$event['eventName']] = [
'process',
$event['priority'],
];
}
return $return;
}