/** * Build replacement map for installed packages. * * @param RepositoryInterface $repository * * @return array */ protected function calculateLegacyReplaceMap(RepositoryInterface $repository) { $replaceMap = array(); try { $abandon = Downloader::download('https://legacy-packages-via.contao-community-alliance.org/abandoned.json'); } catch (\Exception $exception) { Messages::addError($exception->getMessage()); return array(); } $legacyReplaces = json_decode($abandon, true); /** @var \Composer\Package\PackageInterface $package */ foreach ($repository->getPackages() as $package) { if (isset($legacyReplaces[$package->getName()])) { $replaceMap[$package->getName()] = $legacyReplaces[$package->getName()]; } } return $replaceMap; }
/** * Build replacement map for installed packages. * * @param RepositoryInterface $repository * * @return array */ protected function calculateLegacyReplaceMap(RepositoryInterface $repository) { $replaceMap = array(); $legacyReplaces = json_decode(Downloader::download('http://legacy-packages-via.contao-community-alliance.org/abandoned.json'), true); /** @var \Composer\Package\PackageInterface $package */ foreach ($repository->getPackages() as $package) { if (isset($legacyReplaces[$package->getName()])) { $replaceMap[$package->getName()] = $legacyReplaces[$package->getName()]; } } return $replaceMap; }
/** * Load and install the composer.phar. * * @return bool * * @throws \Exception When a download exception occured. */ public static function updateComposer() { $url = 'https://getcomposer.org/composer.phar'; $file = COMPOSER_DIR_ABSOULTE . '/composer.phar'; $tmpFile = COMPOSER_DIR_ABSOULTE . '/composer.new.phar'; $backup = COMPOSER_DIR_ABSOULTE . '/composer.previous.phar'; try { Downloader::download($url, $tmpFile); } catch (\Exception $exception) { unlink($tmpFile); throw $exception; } if (is_file($backup)) { unlink($backup); } rename($file, $backup); rename($tmpFile, $file); return true; }
/** * Load and install the composer.phar. * * @return bool */ public static function updateComposer() { $url = 'https://getcomposer.org/composer.phar'; $file = COMPOSER_DIR_ABSOULTE . '/composer.phar'; Downloader::download($url, $file); return true; }