getInstallationManager example

use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;

class Plugin implements PluginInterface
{
    /** @var Installer */
    private $installer;

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

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

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

  protected function getPackagePath(PackageInterface $package) {
    if ($package->getName() == $this->composer->getPackage()->getName()) {
      // This will respect the --working-dir option if Composer is invoked with       // it. There is no API or method to determine the filesystem path of       // a package's composer.json file.       return getcwd();
    }
    return $this->composer->getInstallationManager()->getInstallPath($package);
  }

}
/** * Gets the installed path for a package. * * @param \Composer\Package\PackageInterface $package * The package. * * @return string * Path to the install path for the package, relative to the project. This * accounts for changes made by composer/installers, if any. */
  protected function getInstallPathForPackage(PackageInterface $package) {
    return $this->composer->getInstallationManager()->getInstallPath($package);
  }

  /** * Clean all configured packages. * * This applies in the context of a post-command event. */
  public function cleanAllPackages() {
    // Get a list of all the packages available after the update or install     // command.     $installed_packages = [];
    
Home | Imprint | This part of the site doesn't use cookies.