Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\DependencyInjection\Loader; Chris@0: Chris@0: /** Chris@0: * DirectoryLoader is a recursive loader to go through directories. Chris@0: * Chris@0: * @author Sebastien Lavoie Chris@0: */ Chris@0: class DirectoryLoader extends FileLoader Chris@0: { Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function load($file, $type = null) Chris@0: { Chris@0: $file = rtrim($file, '/'); Chris@0: $path = $this->locator->locate($file); Chris@14: $this->container->fileExists($path, false); Chris@0: Chris@0: foreach (scandir($path) as $dir) { Chris@0: if ('.' !== $dir[0]) { Chris@0: if (is_dir($path.'/'.$dir)) { Chris@0: $dir .= '/'; // append / to allow recursion Chris@0: } Chris@0: Chris@0: $this->setCurrentDir($path); Chris@0: Chris@0: $this->import($dir, null, false, $path); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function supports($resource, $type = null) Chris@0: { Chris@0: if ('directory' === $type) { Chris@0: return true; Chris@0: } Chris@0: Chris@17: return null === $type && \is_string($resource) && '/' === substr($resource, -1); Chris@0: } Chris@0: }