<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ * $Id$
+ *
+ */
+
+
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\FileLocator;
);
foreach ($locations as $location) {
$path = \CRM_Utils_File::addTrailingSlash(dirname($location)) . str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
- 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.
+ }
}
}