/** * {@inheritDoc} */ public function update(WritableRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { if (!$repo->hasPackage($initial)) { throw new \InvalidArgumentException('Package is not installed: ' . $initial); } $repo->removePackage($initial); $repo->addPackage(clone $target); }
/** * @param string $name * @param string $version * @param string $newName * @return null|Package */ protected static function createPackage($name, $version, $newName) { if (!isset(self::$config['repositories'])) { return null; } $package = null; foreach (self::$config['repositories'] as $cursor) { if (isset($cursor['package']['name'], $cursor['package']['version']) && $cursor['package']['name'] === $name && ($version === '*' || $cursor['package']['version'] === $version)) { $package = $cursor['package']; break; } } if (!$package) { return null; } $new = self::bindPackageValues($newName, $package); self::$localRepo->addPackage($new); return $new; }
/** * {@inheritDoc} */ public function update(WritableRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { if (!$repo->hasPackage($initial)) { throw new \InvalidArgumentException('Package is not installed: ' . $initial); } $this->initializeVendorDir(); $downloadPath = $this->getInstallPath($initial); $this->removeBinaries($initial); $this->downloadManager->update($initial, $target, $downloadPath); $this->installBinaries($target); $repo->removePackage($initial); if (!$repo->hasPackage($target)) { $repo->addPackage(clone $target); } }
/** * Inject the contao/*-bundle versions into the Contao package. * * @param WritableRepositoryInterface $repository The repository where to add the packages. * * @param string $version The version to use. * * @param string $prettyVersion The version to use. * * @return void */ protected function injectContaoBundles(WritableRepositoryInterface $repository, $version, $prettyVersion) { foreach (Environment::$bundleNames as $bundleName) { if ($remove = $repository->findPackage($bundleName, '*')) { if ($this->isNotMetaPackageOrHasSameVersion($remove, $version)) { // stop if the package is required somehow and must not be injected or if the virtual package is // already injected. continue; } // Otherwise remove the package. $repository->removePackage($remove); } $package = new CompletePackage($bundleName, $version, $prettyVersion); $package->setType('metapackage'); $repository->addPackage($package); } }