From 56f473a073f35b2a67f49b3b99dc62f2708f3f5f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 3 Jul 2012 18:19:03 +0200 Subject: [PATCH] [Process] Add extra dirs argument to the executable finder to allow searching more dirs --- src/Symfony/Component/Process/ExecutableFinder.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 1f7fd9090a..7c724577b6 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -43,12 +43,13 @@ class ExecutableFinder /** * Finds an executable by name. * - * @param string $name The executable name (without the extension) - * @param string $default The default to return if no executable is found + * @param string $name The executable name (without the extension) + * @param string $default The default to return if no executable is found + * @param array $extraDirs Additional dirs to check into * * @return string The executable path or default value */ - public function find($name, $default = null) + public function find($name, $default = null, array $extraDirs = array()) { if (ini_get('open_basedir')) { $searchPath = explode(PATH_SEPARATOR, getenv('open_basedir')); @@ -64,7 +65,10 @@ class ExecutableFinder } } } else { - $dirs = explode(PATH_SEPARATOR, getenv('PATH') ? getenv('PATH') : getenv('Path')); + $dirs = array_merge( + explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')), + $extraDirs + ); } $suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : $this->suffixes) : array('');