Skip to content

Commit

Permalink
Fix two more php-finding regexes
Browse files Browse the repository at this point in the history
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 civicrm#16377
  • Loading branch information
ejegg committed Feb 21, 2020
1 parent 57b3fc6 commit f69786e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Civi/Api4/Action/Entity/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getRecords() {
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)
Expand Down
2 changes: 1 addition & 1 deletion Civi/Api4/Action/GetActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private function scanDir($dir) {
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')) {
Expand Down

0 comments on commit f69786e

Please sign in to comment.