Use Symfony ExecutableFinder instead of custom autodetect method

This commit is contained in:
Romain Neutron 2012-04-13 14:43:35 +02:00
commit 70f963f347

View file

@ -37,7 +37,9 @@ abstract class Binary implements AdapterInterface
public static function load(\Monolog\Logger $logger = null)
{
if ('' === $binary = self::autodetect(static::getBinaryName()))
$finder = new \Symfony\Component\Process\ExecutableFinder();
if (null === $binary = $finder->find(static::getBinaryName()))
{
throw new Exception\BinaryNotFoundException('Binary not found');
}
@ -61,17 +63,6 @@ abstract class Binary implements AdapterInterface
return $result;
}
/**
* Autodetect the presence of a binary
*
* @param string $binaryName
* @return string
*/
protected static function autodetect($binaryName)
{
return trim(self::run(sprintf('which %s', escapeshellarg($binaryName)), true));
}
protected static function getBinaryName()
{
throw new Exception('Should be implemented');