From bd2669eacb338cdb5084155fb83e541912b68c49 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 15 Sep 2019 10:51:54 -0400 Subject: [PATCH] Scan core as well as extensions for api4 entities & services --- CRM/Api4/Services.php | 7 +++++-- Civi/Api4/Action/Entity/Get.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CRM/Api4/Services.php b/CRM/Api4/Services.php index ddd889a390..0e78e1a931 100644 --- a/CRM/Api4/Services.php +++ b/CRM/Api4/Services.php @@ -57,8 +57,11 @@ class CRM_Api4_Services { */ public static function loadServices($namespace, $tag, $container) { $namespace = \CRM_Utils_File::addTrailingSlash($namespace, '\\'); - foreach (\CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles() as $ext) { - $path = \CRM_Utils_File::addTrailingSlash(dirname($ext['filePath'])) . str_replace('\\', DIRECTORY_SEPARATOR, $namespace); + $locations = array_merge([\Civi::paths()->getPath('[civicrm.root]/.')], + array_column(\CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles(), 'filePath') + ); + foreach ($locations as $location) { + $path = \CRM_Utils_File::addTrailingSlash(dirname($location)) . str_replace('\\', DIRECTORY_SEPARATOR, $namespace); foreach (glob("$path*.php") as $file) { $matches = []; preg_match('/(\w*).php/', $file, $matches); diff --git a/Civi/Api4/Action/Entity/Get.php b/Civi/Api4/Action/Entity/Get.php index 1d4678cd3c..4f75909524 100644 --- a/Civi/Api4/Action/Entity/Get.php +++ b/Civi/Api4/Action/Entity/Get.php @@ -25,8 +25,11 @@ class Get extends \Civi\Api4\Generic\BasicGetAction { */ protected function getRecords() { $entities = []; - foreach (\CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles() as $ext) { - $dir = \CRM_Utils_File::addTrailingSlash(dirname($ext['filePath'])) . 'Civi/Api4'; + $locations = array_merge([\Civi::paths()->getPath('[civicrm.root]/.')], + array_column(\CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles(), 'filePath') + ); + foreach ($locations as $location) { + $dir = \CRM_Utils_File::addTrailingSlash(dirname($location)) . 'Civi/Api4'; if (is_dir($dir)) { foreach (glob("$dir/*.php") as $file) { $matches = []; -- 2.25.1