4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Loader;
15 * DirectoryLoader is a recursive loader to go through directories.
17 * @author Sebastien Lavoie <seb@wemakecustom.com>
19 class DirectoryLoader extends FileLoader
24 public function load($file, $type = null)
26 $file = rtrim($file, '/');
27 $path = $this->locator->locate($file);
28 $this->container->fileExists($path, false);
30 foreach (scandir($path) as $dir) {
31 if ('.' !== $dir[0]) {
32 if (is_dir($path.'/'.$dir)) {
33 $dir .= '/'; // append / to allow recursion
36 $this->setCurrentDir($path);
38 $this->import($dir, null, false, $path);
46 public function supports($resource, $type = null)
48 if ('directory' === $type) {
52 return null === $type && \is_string($resource) && '/' === substr($resource, -1);