vendor/symfony/src/Symfony/Component/HttpKernel/Config/FileLocator.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     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      * Constructor.
       
    29      *
       
    30      * @param KernelInterface $kernel A KernelInterface instance
       
    31      * @param string          $path   The path the global resource directory
       
    32      * @param string|array    $paths A path or an array of paths where to look for resources
       
    33      */
       
    34     public function __construct(KernelInterface $kernel, $path = null, array $paths = array())
       
    35     {
       
    36         $this->kernel = $kernel;
       
    37         $this->path = $path;
       
    38         $paths[] = $path;
       
    39 
       
    40         parent::__construct($paths);
       
    41     }
       
    42 
       
    43     /**
       
    44      * {@inheritdoc}
       
    45      */
       
    46     public function locate($file, $currentPath = null, $first = true)
       
    47     {
       
    48         if ('@' === $file[0]) {
       
    49             return $this->kernel->locateResource($file, $this->path, $first);
       
    50         }
       
    51 
       
    52         return parent::locate($file, $currentPath, $first);
       
    53     }
       
    54 }