You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

3 years ago
  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\HttpKernel\Config;
  11. use Symfony\Component\Config\FileLocator as BaseFileLocator;
  12. use Symfony\Component\HttpKernel\KernelInterface;
  13. /**
  14. * FileLocator uses the KernelInterface to locate resources in bundles.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. class FileLocator extends BaseFileLocator
  19. {
  20. private $kernel;
  21. public function __construct(KernelInterface $kernel)
  22. {
  23. $this->kernel = $kernel;
  24. parent::__construct();
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function locate(string $file, string $currentPath = null, bool $first = true)
  30. {
  31. if (isset($file[0]) && '@' === $file[0]) {
  32. $resource = $this->kernel->locateResource($file);
  33. return $first ? $resource : [$resource];
  34. }
  35. return parent::locate($file, $currentPath, $first);
  36. }
  37. }