Skip to content

Commit

Permalink
Merge pull request #30 from chr-hertel/composer2-compatibility
Browse files Browse the repository at this point in the history
Composer 2 Compatibility
  • Loading branch information
mnsami authored Aug 18, 2020
2 parents a4f6eec + 5241627 commit 85f6632
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"minimum-stability": "stable",
"require": {
"php": ">=5.3",
"composer-plugin-api": "^1.0"
"composer-plugin-api": "^1.0 || ^2.0"
},
"autoload": {
"psr-0": {"Composer\\CustomDirectoryInstaller": "src/"}
Expand Down
16 changes: 13 additions & 3 deletions src/Composer/CustomDirectoryInstaller/LibraryPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\CustomDirectoryInstaller\LibraryInstaller;

class LibraryPlugin implements PluginInterface
{
private $installer;

public function activate (Composer $composer, IOInterface $io)
{
$installer = new LibraryInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
$this->installer = new LibraryInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($this->installer);
}

public function deactivate(Composer $composer, IOInterface $io)
{
$composer->getInstallationManager()->removeInstaller($this->installer);
}

public function uninstall(Composer $composer, IOInterface $io)
{
}
}
12 changes: 11 additions & 1 deletion src/Composer/CustomDirectoryInstaller/PearPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\CustomDirectoryInstaller\PearInstaller;

class PearPlugin implements PluginInterface
{
public function activate (Composer $composer, IOInterface $io)
{
if (!class_exists('Composer\Composer\Installer\PearInstaller')) {
return;
}
$installer = new PearInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
}

public function deactivate(Composer $composer, IOInterface $io)
{
}

public function uninstall(Composer $composer, IOInterface $io)
{
}
}
16 changes: 13 additions & 3 deletions src/Composer/CustomDirectoryInstaller/PluginPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\CustomDirectoryInstaller\PluginInstaller;

class PluginPlugin implements PluginInterface
{
private $installer;

public function activate (Composer $composer, IOInterface $io)
{
$installer = new PluginInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
$this->installer = new PluginInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($this->installer);
}

public function deactivate(Composer $composer, IOInterface $io)
{
$composer->getInstallationManager()->removeInstaller($this->installer);
}

public function uninstall(Composer $composer, IOInterface $io)
{
}
}

0 comments on commit 85f6632

Please sign in to comment.