vendor/symfony/dependency-injection/Loader/DirectoryLoader.php line 48

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\DependencyInjection\Loader;
  11. /**
  12.  * DirectoryLoader is a recursive loader to go through directories.
  13.  *
  14.  * @author Sebastien Lavoie <seb@wemakecustom.com>
  15.  */
  16. class DirectoryLoader extends FileLoader
  17. {
  18.     /**
  19.      * {@inheritdoc}
  20.      */
  21.     public function load($filestring $type null)
  22.     {
  23.         $file rtrim($file'/');
  24.         $path $this->locator->locate($file);
  25.         $this->container->fileExists($pathfalse);
  26.         foreach (scandir($path) as $dir) {
  27.             if ('.' !== $dir[0]) {
  28.                 if (is_dir($path.'/'.$dir)) {
  29.                     $dir .= '/'// append / to allow recursion
  30.                 }
  31.                 $this->setCurrentDir($path);
  32.                 $this->import($dirnullfalse$path);
  33.             }
  34.         }
  35.         return null;
  36.     }
  37.     /**
  38.      * {@inheritdoc}
  39.      */
  40.     public function supports($resourcestring $type null)
  41.     {
  42.         if ('directory' === $type) {
  43.             return true;
  44.         }
  45.         return null === $type && \is_string($resource) && str_ends_with($resource'/');
  46.     }
  47. }