Show disabled membership types on contact tab
[civicrm-core.git] / CRM / Api4 / Services.php
index 736866af6a391c86881a1b1ed9e27585699e3d7f..f7fc52befc9c94eca183d19921e62f5ec819955a 100644 (file)
@@ -14,8 +14,6 @@
  *
  * @package CRM
  * @copyright CiviCRM LLC https://civicrm.org/licensing
- * $Id$
- *
  */
 
 
@@ -81,9 +79,12 @@ class CRM_Api4_Services {
     );
     foreach ($locations as $location) {
       $path = \CRM_Utils_File::addTrailingSlash(dirname($location)) . str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
-      try {
+      if (!file_exists($path) || !is_dir($path)) {
+        $resource = new \Symfony\Component\Config\Resource\FileExistenceResource($path);
+        $container->addResource($resource);
+      }
+      else {
         $resource = new \Symfony\Component\Config\Resource\DirectoryResource($path, ';\.php$;');
-        $addResource = false;
         foreach (glob("$path*.php") as $file) {
           $matches = [];
           preg_match('/(\w*)\.php$/', $file, $matches);
@@ -92,15 +93,9 @@ class CRM_Api4_Services {
           if ($serviceClass->isInstantiable()) {
             $definition = $container->register(str_replace('\\', '_', $serviceName), $serviceName);
             $definition->addTag($tag);
-            $addResource = true;
           }
         }
-        if ($addResource) {
-          $container->addResource($resource);
-        }
-      }
-      catch (\InvalidArgumentException $e) {
-        //Directory is not found so lets not do anything i suppose.
+        $container->addResource($resource);
       }
     }
   }