From b1ad92c90fc45480ee81cca29cec5692d77ff2af Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 8 Nov 2019 10:07:32 +1100 Subject: [PATCH] dev/core#1376 Catch Invalid Argument Exception when looking for APIv4 Services --- CRM/Api4/Services.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/CRM/Api4/Services.php b/CRM/Api4/Services.php index 03dcf6c5af..9a39295d65 100644 --- a/CRM/Api4/Services.php +++ b/CRM/Api4/Services.php @@ -97,17 +97,23 @@ class CRM_Api4_Services { ); foreach ($locations as $location) { $path = \CRM_Utils_File::addTrailingSlash(dirname($location)) . str_replace('\\', DIRECTORY_SEPARATOR, $namespace); - $container->addResource(new \Symfony\Component\Config\Resource\DirectoryResource($path, ';\.php$;')); - foreach (glob("$path*.php") as $file) { - $matches = []; - preg_match('/(\w*).php/', $file, $matches); - $serviceName = $namespace . array_pop($matches); - $serviceClass = new \ReflectionClass($serviceName); - if ($serviceClass->isInstantiable()) { - $definition = $container->register(str_replace('\\', '_', $serviceName), $serviceName); - $definition->addTag($tag); + try { + $resource = new \Symfony\Component\Config\Resource\DirectoryResource($path, ';\.php$;'); + $container->addResource($resource); + foreach (glob("$path*.php") as $file) { + $matches = []; + preg_match('/(\w*).php/', $file, $matches); + $serviceName = $namespace . array_pop($matches); + $serviceClass = new \ReflectionClass($serviceName); + if ($serviceClass->isInstantiable()) { + $definition = $container->register(str_replace('\\', '_', $serviceName), $serviceName); + $definition->addTag($tag); + } } } + catch (\InvalidArgumentException $e) { + //Directory is not found so lets not do anything i suppose. + } } } -- 2.25.1