(REF) CRM_Api4_Services - Switch to EventScanner
authorTim Otten <totten@civicrm.org>
Wed, 26 May 2021 23:05:15 +0000 (16:05 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 26 May 2021 23:52:24 +0000 (16:52 -0700)
CRM/Api4/Services.php

index 47b428403148fd0300727d46b8c16dfbbb07057a..fe88674de4de73d9acb5c283db6eb20121428041 100644 (file)
@@ -16,7 +16,7 @@
  * @copyright CiviCRM LLC https://civicrm.org/licensing
  */
 
-
+use Civi\Core\Event\EventScanner;
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\Config\FileLocator;
@@ -43,11 +43,8 @@ class CRM_Api4_Services {
     $subscribers = $container->findTaggedServiceIds('event_subscriber');
 
     foreach (array_keys($subscribers) as $subscriber) {
-      $getSubscribedEvents = [$container->findDefinition($subscriber)->getClass(), 'getSubscribedEvents'];
-      $dispatcher->addMethodCall(
-        'addSubscriberServiceMap',
-        [$subscriber, $getSubscribedEvents()]
-      );
+      $listenerMap = EventScanner::findListeners($container->findDefinition($subscriber)->getClass());
+      $dispatcher->addMethodCall('addSubscriberServiceMap', [$subscriber, $listenerMap]);
     }
 
     // add spec providers