/** * Convert the information of all packages in a repository to an array used by json API. * * @param RepositoryInterface $repository The repository holding the packages to convert. * * @param bool $requiredOnly If true, return only the packages added to the root package as * require. * * @param null|RepositoryInterface $upgradeList The packages available as upgrades. * * @return JsonArray */ public function convertRepositoryToArray(RepositoryInterface $repository, $requiredOnly = false, RepositoryInterface $upgradeList = null) { $requires = $requiredOnly ? $this->rootPackage->getRequires() : false; $packages = new JsonArray(); /** @var \Composer\Package\PackageInterface $package */ foreach ($repository->getPackages() as $package) { $name = $package->getPrettyName(); $esc = $packages->escape($name); if (false === $requires || isset($requires[$name])) { $upgradePkg = null; if ($upgradeList) { $upgradePkg = $upgradeList->findPackage($name, '*'); } $packages->set($esc, $this->convertPackageToArray($package, $upgradePkg)->getData()); } } return $packages; }
/** * {@inheritDoc} */ public function uninstall(RepositoryInterface $repo, UninstallOperation $operation) { $this->packageInformation->set($this->packageInformation->escape($operation->getPackage()->getPrettyName()), ['type' => 'uninstall', 'package' => $this->dumper->dump($operation->getPackage())]); parent::uninstall($repo, $operation); }