diff --git a/src/Engine/EngineBase.php b/src/Engine/EngineBase.php index 5cf9aad..894a888 100644 --- a/src/Engine/EngineBase.php +++ b/src/Engine/EngineBase.php @@ -274,6 +274,17 @@ public function shellWhich($command) { return $cache[$command]; } + // Look at manual aliases. + $alias = $this->converter->getCommandAlias($command); + if (isset($alias)) { + $path = realpath($alias); + if ($path === FALSE) { + $path = NULL; + } + $cache[$command] = $path; + return $path; + } + // Look in the bin folder for FileConverter-provided bins (symlinks work fine). $bin = realpath(__DIR__ . '/../../bin/' . $command); if ($bin !== FALSE && is_executable($bin)) { diff --git a/src/FileConverter.php b/src/FileConverter.php index 01d4996..276570e 100644 --- a/src/FileConverter.php +++ b/src/FileConverter.php @@ -40,7 +40,9 @@ static public function &factory($get_singleton = TRUE) { } protected $configurations = array(); - protected $settings = array(); + protected $settings = array( + 'alias' => array(), + ); protected $missing_engines = array(); protected $previous_engines = array(); protected $conversion_depth = 0; @@ -167,6 +169,13 @@ public function convertString($source, &$destination, $convert_path = 'null->nul return $this; } + public function getCommandAlias($command) { + if (isset($this->settings['alias'][$command])) { + return $this->settings['alias'][$command]; + } + return NULL; + } + public function getConvertedString($source, $convert_path = 'null->null') { $destination = ''; $this->convertString($source, $destination, $convert_path); @@ -274,7 +283,7 @@ public function getEngines($convert_path, $configuration_overrides = NULL, $conf // This is similar to setConverter('a->b', 'force_id'), // except that it might not be the first engine tried. if (isset($configuration['#final'])) { - break(2); + break (2); } } } @@ -333,6 +342,10 @@ public function optimizeFile($source = NULL, $destination = NULL, $ext = NULL) { return $this->convert('file', "$ext->$ext", $source, $destination); } + public function &setCommandAlias($alias, $path) { + $this->settings['alias'][$alias] = $path; + } + public function &setConverter($convert_path = 'null->null', $configuration = 'null:default') { $conf = new ConfigurationOverride($this->settings); $conf->setConverter($convert_path, $configuration);