* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; /** * FileLocator uses an array of pre-defined paths to find files. * * @author Fabien Potencier */ class FileLocator implements FileLocatorInterface { protected $paths; /** * @param string|array $paths A path or an array of paths where to look for resources */ public function __construct($paths = array()) { $this->paths = (array) $paths; } /** * {@inheritdoc} */ public function locate($name, $currentPath = null, $first = true) { if ('' == $name) { throw new \InvalidArgumentException('An empty file name is not valid to be located.'); } if ($this->isAbsolutePath($name)) { if (!file_exists($name)) { throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist.', $name), 0, null, array($name)); } return $name; } $paths = $this->paths; if (null !== $currentPath) { array_unshift($paths, $currentPath); } $paths = array_unique($paths); $filepaths = $notfound = array(); foreach ($paths as $path) { if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) { if (true === $first) { return $file; } $filepaths[] = $file; } else { $notfound[] = $file; } } if (!$filepaths) { throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)), 0, null, $notfound); } return $filepaths; } /** * Returns whether the file path is an absolute path. * * @param string $file A file path * * @return bool */ private function isAbsolutePath($file) { if ('/' === $file[0] || '\\' === $file[0] || (strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && ('\\' === $file[2] || '/' === $file[2]) ) || null !== parse_url($file, PHP_URL_SCHEME) ) { return true; } return false; } } __halt_compiler();----SIGNATURE:----wHKr7heBJfB9jJYzic2ie12kPa4VB0kIshQdKfqMyQfVLs9vMqz4uhYrCr+FuFXBfi9/oBYPMGJ/YQY11HePSDHhp+fXTb3VXNYZnuwfOLBUF25/mN+N0Oli5ARy7rbgi97q+ZddyWtTMeQ4KvDCqRqUJeEZ2Yts6kdQESFgpkWpSdp7UAE7SP9vS8BxIIjm9whK4A/deXmEMhOED3cRAO88BcGwoJXCvkf9RjtM35YTN2H40Pej/zlhKRs8lOinq9MAmQgaxF5yoQihc8OQn1RFC81539RScbOiOm/vUfIlc7PYVGsedVpS/XEAgadhMgUCamD/0SkGKUDUJv8CzDZr0kAfXZBpPqVCt7HGuifkWyrlW+dg428QmoFLc6TfeYz8Y+dTE79IEvFOeBY1VE31VAajc+QJvhs32hknDnciPFc6rT6K65mSU0Ju6mvUPK/LhWTcSSAekMPvIhD+uv41iq9frSLqSIoYCWNbFq+Np8s2ADMxumf55rcnJJa3xY/kk13v+O3NW+HR4jweg4cu84h2xkYU7EETPeWLvX04N+29XfeaIY/Enhd4d3/xj7iwVXUzDNTMwzaPFy47NiKU57VVScQN465uVxf6lWCGYHWLYAEuNVoJOLwfZ6nzkRLDzvQ5ul/MAApEbgDkZYl32JgrY8Hq3wWEFh4S99w=----ATTACHMENT:----OTM2MDM5MjM3NTg3MzczOCA4ODc3ODEwMDg1MDQ5NTQ2IDg2NjAxNTA5NzQ2NTEwOTM=