return array_values(self::daoToClass());
}
+ /**
+ * Get a list of all extant BAO classes.
+ *
+ * @return array
+ * Ex: ['Contact' => 'CRM_Contact_BAO_Contact']
+ */
+ public static function getBaoClasses() {
+ $r = [];
+ foreach (\CRM_Core_DAO_AllCoreTables::daoToClass() as $entity => $daoClass) {
+ $baoClass = str_replace('_DAO_', '_BAO_', $daoClass);
+ if (class_exists($baoClass)) {
+ $r[$entity] = $baoClass;
+ }
+ }
+ return $r;
+ }
+
/**
* Get the classname for the table.
*
<?php
namespace Civi\Core;
+use Civi\Core\Event\EventScanner;
use Civi\Core\Lock\LockManager;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\DependencyInjection\ContainerBuilder;
))->addTag('kernel.event_subscriber')->setPublic(TRUE);
}
+ $dispatcherDefn = $container->getDefinition('dispatcher');
+ foreach (\CRM_Core_DAO_AllCoreTables::getBaoClasses() as $baoEntity => $baoClass) {
+ $listenerMap = EventScanner::findListeners($baoClass, $baoEntity);
+ if ($listenerMap) {
+ $file = (new \ReflectionClass($baoClass))->getFileName();
+ $container->addResource(new \Symfony\Component\Config\Resource\FileResource($file));
+ $dispatcherDefn->addMethodCall('addListenerMap', [$baoClass, $listenerMap]);
+ }
+ }
+
\CRM_Api4_Services::hook_container($container);
\CRM_Utils_Hook::container($container);