예제 #1
0
 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()));
 }
 private function loadInstallers(Package $package)
 {
     foreach (self::$builtinInstallers as $name => $installerData) {
         $installer = $this->dataToInstaller($name, (object) $installerData);
         $this->installerDescriptors[$name] = $installer;
     }
     $packageFile = $package->getPackageFile();
     if (!$packageFile) {
         return;
     }
     $packageName = $package->getName();
     $installersData = $packageFile->getExtraKey(self::INSTALLERS_KEY);
     if (!$installersData) {
         return;
     }
     $jsonValidator = new JsonValidator();
     $errors = $jsonValidator->validate($installersData, __DIR__ . '/../../res/schema/installers-schema-1.0.json');
     if (count($errors) > 0) {
         throw new ValidationFailedException(sprintf("The extra key \"%s\" of package \"%s\" is invalid:\n%s", self::INSTALLERS_KEY, $packageName, implode("\n", $errors)));
     }
     foreach ($installersData as $name => $installerData) {
         $installer = $this->dataToInstaller($name, $installerData);
         $this->installerDescriptors[$name] = $installer;
         if ($package instanceof RootPackage) {
             $this->rootInstallerDescriptors[$name] = $installer;
         }
     }
 }