private function makeAbsolute($relativePath, Package $containingPackage, PackageCollection $packages) { // Reference to install path of other package if ('@' !== $relativePath[0] || false === ($pos = strpos($relativePath, ':'))) { return $containingPackage->getInstallPath() . '/' . $relativePath; } $refPackageName = substr($relativePath, 1, $pos - 1); if (!$packages->contains($refPackageName)) { throw new NoSuchPackageException(sprintf('The package "%s" referenced in the resource path "%s" was not ' . 'found. Maybe the package is not installed?', $refPackageName, $relativePath)); } $refPackage = $packages->get($refPackageName); return $refPackage->getInstallPath() . '/' . substr($relativePath, $pos + 1); }
private function renameNonRootPackage(Package $package, $newName) { $previousInstallInfo = $package->getInstallInfo(); $installInfo = new InstallInfo($newName, $previousInstallInfo->getInstallPath()); $installInfo->setInstallerName($previousInstallInfo->getInstallerName()); foreach ($previousInstallInfo->getEnabledBindingUuids() as $uuid) { $installInfo->addEnabledBindingUuid($uuid); } foreach ($previousInstallInfo->getDisabledBindingUuids() as $uuid) { $installInfo->addDisabledBindingUuid($uuid); } $this->rootPackageFile->removeInstallInfo($package->getName()); $this->rootPackageFile->addInstallInfo($installInfo); try { $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile); } catch (Exception $e) { $this->rootPackageFile->removeInstallInfo($newName); $this->rootPackageFile->addInstallInfo($previousInstallInfo); throw $e; } $this->packages->remove($package->getName()); $this->packages->add(new Package($package->getPackageFile(), $package->getInstallPath(), $installInfo, $package->getLoadErrors())); }