Show disabled membership types on contact tab
[civicrm-core.git] / CRM / Api4 / Services.php
index ec8190348ccd3c7a63107cdf5279eae49f5760b8..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 {
-        $resource = new \Symfony\Component\Config\Resource\DirectoryResource($path, ';\.php$;');
+      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$;');
         foreach (glob("$path*.php") as $file) {
           $matches = [];
           preg_match('/(\w*)\.php$/', $file, $matches);
@@ -94,9 +95,7 @@ class CRM_Api4_Services {
             $definition->addTag($tag);
           }
         }
-      }
-      catch (\InvalidArgumentException $e) {
-        //Directory is not found so lets not do anything i suppose.
+        $container->addResource($resource);
       }
     }
   }