Implement a plugin manager and interface, update installer plugin tests
parent
01a08a2ff3
commit
eb966d347f
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Plugin;
|
||||
|
||||
use Composer\Composer;
|
||||
|
||||
/**
|
||||
* Plugin interface
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
interface PluginInterface
|
||||
{
|
||||
/**
|
||||
* Apply plugin modifications to the passed in composer object
|
||||
*
|
||||
* @param Composer $composer
|
||||
*/
|
||||
public function activate(Composer $composer);
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Plugin;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* Plugin manager
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class PluginManager
|
||||
{
|
||||
protected $composer;
|
||||
|
||||
protected $plugins = array();
|
||||
|
||||
/**
|
||||
* Initializes plugin manager
|
||||
*
|
||||
* @param Composer $composer
|
||||
*/
|
||||
public function __construct(Composer $composer)
|
||||
{
|
||||
$this->composer = $composer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds plugin
|
||||
*
|
||||
* @param PluginInterface $plugin plugin instance
|
||||
*/
|
||||
public function addPlugin(PluginInterface $plugin)
|
||||
{
|
||||
$this->plugins[] = $plugin;
|
||||
$plugin->activate($this->composer);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Installer\InstallerInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
|
||||
class Custom implements InstallerInterface
|
||||
{
|
||||
public $version = 'installer-v1';
|
||||
|
||||
public function supports($packageType) {}
|
||||
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) {}
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function getInstallPath(PackageInterface $package) {}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
|
||||
class Plugin implements PluginInterface
|
||||
{
|
||||
public $version = 'installer-v1';
|
||||
|
||||
public function activate(Composer $composer)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Installer\InstallerInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
|
||||
class Custom2 implements InstallerInterface
|
||||
{
|
||||
public $version = 'installer-v2';
|
||||
|
||||
public function supports($packageType) {}
|
||||
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) {}
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function getInstallPath(PackageInterface $package) {}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
|
||||
class Plugin2 implements PluginInterface
|
||||
{
|
||||
public $version = 'installer-v2';
|
||||
|
||||
public function activate(Composer $composer)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Installer\InstallerInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
|
||||
class Custom2 implements InstallerInterface
|
||||
{
|
||||
public $version = 'installer-v3';
|
||||
|
||||
public function supports($packageType) {}
|
||||
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) {}
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function getInstallPath(PackageInterface $package) {}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
|
||||
class Plugin2 implements PluginInterface
|
||||
{
|
||||
public $version = 'installer-v3';
|
||||
|
||||
public function activate(Composer $composer)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Installer\InstallerInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
|
||||
class Custom1 implements InstallerInterface
|
||||
{
|
||||
public $name = 'custom1';
|
||||
public $version = 'installer-v4';
|
||||
|
||||
public function supports($packageType) {}
|
||||
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) {}
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function getInstallPath(PackageInterface $package) {}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Installer\InstallerInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
|
||||
class Custom2 implements InstallerInterface
|
||||
{
|
||||
public $name = 'custom2';
|
||||
public $version = 'installer-v4';
|
||||
|
||||
public function supports($packageType) {}
|
||||
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) {}
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) {}
|
||||
public function getInstallPath(PackageInterface $package) {}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
|
||||
class Plugin1 implements PluginInterface
|
||||
{
|
||||
public $name = 'plugin1';
|
||||
public $version = 'installer-v4';
|
||||
|
||||
public function activate(Composer $composer)
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Installer;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
|
||||
class Plugin2 implements PluginInterface
|
||||
{
|
||||
public $name = 'plugin2';
|
||||
public $version = 'installer-v4';
|
||||
|
||||
public function activate(Composer $composer)
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue