From 4f7fbbc879c88e1878551d715e1c537cc56dd410 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 31 May 2016 12:19:53 +0200 Subject: [PATCH] Introduce InstallerBinaryInterface This is an interface for Installer which should support installing binary. ATM there is only the `LibraryInstaller`. It eases the check for supported method when installing binaries for all packages --- src/Composer/Installer.php | 2 +- .../Installer/InstallationManager.php | 9 ++++-- .../Installer/InstallerBinaryInterface.php | 31 +++++++++++++++++++ src/Composer/Installer/LibraryInstaller.php | 2 +- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 src/Composer/Installer/InstallerBinaryInterface.php diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 7ba1ab59a..0a4bda6f0 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -340,7 +340,7 @@ class Installer // force binaries re-generation $this->io->writeError('Installing binaries files'); foreach ($localRepo->getPackages() as $package) { - $this->installationManager->installBinary($package); + $this->installationManager->installBinary($package); } $vendorDir = $this->config->get('vendor-dir'); diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index 96a194232..6734aa7e3 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -137,9 +137,14 @@ class InstallationManager { try { $installer = $this->getInstaller($package->getType()); - $installer->installBinary($package); } catch (\InvalidArgumentException $e) { - // the given installer doesn't support installing binaries + // no installer found for the current package type (@see `getInstaller()`) + return; + } + + // if the given installer support installing binaries + if ($installer instanceof InstallerBinaryInterface) { + $installer->installBinary($package); } } diff --git a/src/Composer/Installer/InstallerBinaryInterface.php b/src/Composer/Installer/InstallerBinaryInterface.php new file mode 100644 index 000000000..e87a62bd3 --- /dev/null +++ b/src/Composer/Installer/InstallerBinaryInterface.php @@ -0,0 +1,31 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Installer; + +use Composer\Package\PackageInterface; + +/** + * Interface for the package installation manager that handle binary installation. + * + * @author Konstantin Kudryashov + * @author Jordi Boggiano + */ +interface InstallerBinaryInterface +{ + /** + * Installs binary file for a specific package. + * + * @param PackageInterface $package package instance + */ + public function installBinary(PackageInterface $package); +} diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 0b8444d6a..bd929062f 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -25,7 +25,7 @@ use Composer\Util\Silencer; * @author Jordi Boggiano * @author Konstantin Kudryashov */ -class LibraryInstaller implements InstallerInterface +class LibraryInstaller implements InstallerInterface, InstallerBinaryInterface { protected $composer; protected $vendorDir;