2 namespace TYPO3\CMS\Composer\Installer;
27 use Composer\Package\PackageInterface;
70 $this->downloadManager = $composer->getDownloadManager();
72 $this->filesystem =
$filesystem ? : new \Composer\Util\Filesystem();
88 $configDir = $this->filesystem->normalizePath($this->pluginConfig->get(
'config-dir'));
89 $this->extensionDir = $configDir . DIRECTORY_SEPARATOR . self::TYPO3_EXT_DIR;
99 return $packageType !==
'typo3-cms-core'
101 && strncmp(
'typo3-cms-', $packageType, 10) === 0;
112 public function isInstalled(\Composer\Repository\InstalledRepositoryInterface $repo, PackageInterface $package) {
113 return $repo->hasPackage($package) && is_readable($this->
getInstallPath($package));
122 public function install(\Composer\Repository\InstalledRepositoryInterface $repo, PackageInterface $package) {
124 if (!$repo->hasPackage($package)) {
125 $repo->addPackage(clone $package);
138 public function update(\Composer\Repository\InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) {
139 if (!$repo->hasPackage($initial)) {
140 throw new \InvalidArgumentException(
'Package is not installed: ' . $initial);
143 $repo->removePackage($initial);
144 if (!$repo->hasPackage($target)) {
145 $repo->addPackage(clone $target);
157 public function uninstall(\Composer\Repository\InstalledRepositoryInterface $repo, PackageInterface $package) {
158 if (!$repo->hasPackage($package)) {
159 throw new \InvalidArgumentException(
'Package is not installed: ' . $package);
163 $repo->removePackage($package);
174 foreach ($package->getReplaces() as $packageName => $version) {
175 if (strpos($packageName,
'/') === FALSE) {
176 $extensionKey = trim($packageName);
180 if (empty($extensionKey)) {
181 list(, $extensionKey) = explode(
'/', $package->getName(), 2);
182 $extensionKey = str_replace(
'-',
'_', $extensionKey);
184 return $this->extensionDir . DIRECTORY_SEPARATOR . $extensionKey;
191 $this->downloadManager->download($package, $this->
getInstallPath($package));
198 protected function updateCode(PackageInterface $initial, PackageInterface $target) {
201 if ($targetDownloadPath !== $initialDownloadPath) {
204 if (substr($initialDownloadPath, 0, strlen($targetDownloadPath)) === $targetDownloadPath
205 || substr($targetDownloadPath, 0, strlen($initialDownloadPath)) === $initialDownloadPath
213 $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
215 $this->downloadManager->update($initial, $target, $targetDownloadPath);
222 $this->downloadManager->remove($package, $this->
getInstallPath($package));