c047ba3dac389b6af51d54360ef92d5a816cdef8
[yaffs-website] / vendor / symfony / http-kernel / Config / FileLocator.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\HttpKernel\Config;
13
14 use Symfony\Component\Config\FileLocator as BaseFileLocator;
15 use Symfony\Component\HttpKernel\KernelInterface;
16
17 /**
18  * FileLocator uses the KernelInterface to locate resources in bundles.
19  *
20  * @author Fabien Potencier <fabien@symfony.com>
21  */
22 class FileLocator extends BaseFileLocator
23 {
24     private $kernel;
25     private $path;
26
27     /**
28      * @param KernelInterface $kernel A KernelInterface instance
29      * @param string|null     $path   The path the global resource directory
30      * @param array           $paths  An array of paths where to look for resources
31      */
32     public function __construct(KernelInterface $kernel, $path = null, array $paths = array())
33     {
34         $this->kernel = $kernel;
35         if (null !== $path) {
36             $this->path = $path;
37             $paths[] = $path;
38         }
39
40         parent::__construct($paths);
41     }
42
43     /**
44      * {@inheritdoc}
45      */
46     public function locate($file, $currentPath = null, $first = true)
47     {
48         if (isset($file[0]) && '@' === $file[0]) {
49             return $this->kernel->locateResource($file, $this->path, $first);
50         }
51
52         return parent::locate($file, $currentPath, $first);
53     }
54 }