From 3ba93c648f0ea5959f408294165726d98425d65f Mon Sep 17 00:00:00 2001 From: Elliott Eggleston Date: Thu, 20 Feb 2020 20:34:13 -0500 Subject: [PATCH] Fix two more php-finding regexes Before: Civi code living under a path containing the characters php (such as ~/src/php/civicrm) will fail to load the API4 explorer with a message like the following: ReflectionException: "Class \Civi\Api4\src does not exist" After: API4 explorer loads no matter what the enclosing path Very similar to PR #16377 --- Civi/Api4/Action/Entity/Get.php | 2 +- Civi/Api4/Action/GetActions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Civi/Api4/Action/Entity/Get.php b/Civi/Api4/Action/Entity/Get.php index 2b42ea2375..01980abde1 100644 --- a/Civi/Api4/Action/Entity/Get.php +++ b/Civi/Api4/Action/Entity/Get.php @@ -58,7 +58,7 @@ class Get extends \Civi\Api4\Generic\BasicGetAction { if (is_dir($dir)) { foreach (glob("$dir/*.php") as $file) { $matches = []; - preg_match('/(\w*).php/', $file, $matches); + preg_match('/(\w*)\.php$/', $file, $matches); if ( (!$toGet || in_array($matches[1], $toGet)) && is_a('\Civi\Api4\\' . $matches[1], '\Civi\Api4\Generic\AbstractEntity', TRUE) diff --git a/Civi/Api4/Action/GetActions.php b/Civi/Api4/Action/GetActions.php index b16fb0a285..e142e20470 100644 --- a/Civi/Api4/Action/GetActions.php +++ b/Civi/Api4/Action/GetActions.php @@ -67,7 +67,7 @@ class GetActions extends BasicGetAction { if (is_dir($dir)) { foreach (glob("$dir/*.php") as $file) { $matches = []; - preg_match('/(\w*).php/', $file, $matches); + preg_match('/(\w*)\.php$/', $file, $matches); $actionName = array_pop($matches); $actionClass = new \ReflectionClass('\\Civi\\Api4\\Action\\' . $this->_entityName . '\\' . $actionName); if ($actionClass->isInstantiable() && $actionClass->isSubclassOf('\\Civi\\Api4\\Generic\\AbstractAction')) { -- 2.25.1