You can pass a base configuration to the constructor that the module's configuration will inherit.
С версии: 1.0
Автор: Bernhard Schussek (bschussek@gmail.com)
Наследование: extends ModuleFile
 public function rollback()
 {
     if ($this->previousDescriptor) {
         $this->rootModuleFile->addTypeDescriptor($this->previousDescriptor);
     } else {
         $this->rootModuleFile->removeTypeDescriptor($this->typeDescriptor->getTypeName());
     }
 }
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if ($this->previousDescriptor) {
         $this->rootModuleFile->addBindingDescriptor($this->previousDescriptor);
     } else {
         $this->rootModuleFile->removeBindingDescriptor($this->bindingDescriptor->getUuid());
     }
 }
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if ($this->previousMapping) {
         $this->rootModuleFile->addPathMapping($this->previousMapping);
     } else {
         $this->rootModuleFile->removePathMapping($this->mapping->getRepositoryPath());
     }
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function addRootPathMapping(PathMapping $mapping, $flags = 0)
 {
     Assert::integer($flags, 'The argument $flags must be a boolean.');
     $this->assertMappingsLoaded();
     if (!($flags & self::OVERRIDE) && $this->rootModuleFile->hasPathMapping($mapping->getRepositoryPath())) {
         throw DuplicatePathMappingException::forRepositoryPath($mapping->getRepositoryPath(), $this->rootModule->getName());
     }
     $tx = new Transaction();
     try {
         $syncOp = $this->syncRepositoryPath($mapping->getRepositoryPath());
         $syncOp->takeSnapshot();
         $tx->execute($this->loadPathMapping($mapping, $this->rootModule));
         if (!($flags & self::IGNORE_FILE_NOT_FOUND)) {
             $this->assertNoLoadErrors($mapping);
         }
         $tx->execute($this->updateConflicts($mapping->listRepositoryPaths()));
         $tx->execute($this->overrideConflictingModules($mapping));
         $tx->execute($this->updateConflicts());
         $tx->execute($this->addPathMappingToModuleFile($mapping));
         $tx->execute($syncOp);
         $this->saveRootModuleFile();
         $tx->commit();
     } catch (Exception $e) {
         $tx->rollback();
         throw $e;
     }
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function migrate($targetVersion)
 {
     $previousVersion = $this->rootModuleFile->getVersion();
     if ($previousVersion === $targetVersion) {
         return;
     }
     $this->rootModuleFile->setVersion($targetVersion);
     try {
         $this->jsonStorage->saveRootModuleFile($this->rootModuleFile);
     } catch (Exception $e) {
         $this->rootModuleFile->setVersion($previousVersion);
         throw $e;
     }
 }
Пример #6
0
 private function renameNonRootModule(Module $module, $newName)
 {
     $previousInstallInfo = $module->getInstallInfo();
     $installInfo = new InstallInfo($newName, $previousInstallInfo->getInstallPath());
     $installInfo->setInstallerName($previousInstallInfo->getInstallerName());
     foreach ($previousInstallInfo->getDisabledBindingUuids() as $uuid) {
         $installInfo->addDisabledBindingUuid($uuid);
     }
     $this->rootModuleFile->removeInstallInfo($module->getName());
     $this->rootModuleFile->addInstallInfo($installInfo);
     try {
         $this->moduleFileStorage->saveRootModuleFile($this->rootModuleFile);
     } catch (Exception $e) {
         $this->rootModuleFile->removeInstallInfo($newName);
         $this->rootModuleFile->addInstallInfo($previousInstallInfo);
         throw $e;
     }
     $this->modules->remove($module->getName());
     $this->modules->add(new Module($module->getModuleFile(), $module->getInstallPath(), $installInfo, $module->getLoadErrors()));
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function removeObsoleteDisabledBindingDescriptors()
 {
     $this->assertModulesLoaded();
     $removedUuidsByModule = array();
     try {
         foreach ($this->rootModuleFile->getInstallInfos() as $installInfo) {
             foreach ($installInfo->getDisabledBindingUuids() as $uuid) {
                 if (!$this->bindingDescriptors->contains($uuid)) {
                     $installInfo->removeDisabledBindingUuid($uuid);
                     $removedUuidsByModule[$installInfo->getModuleName()][] = $uuid;
                 }
             }
         }
         $this->saveRootModuleFile();
     } catch (Exception $e) {
         foreach ($removedUuidsByModule as $moduleName => $removedUuids) {
             $installInfo = $this->rootModuleFile->getInstallInfo($moduleName);
             foreach ($removedUuids as $uuid) {
                 $installInfo->addDisabledBindingUuid($uuid);
             }
         }
         throw $e;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if ($this->previousDescriptor) {
         $this->rootModuleFile->addBindingDescriptor($this->previousDescriptor);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if ($this->previousMapping) {
         $this->rootModuleFile->addPathMapping($this->previousMapping);
     }
 }
Пример #10
0
 /**
  * Creates the context of a Puli project.
  *
  * The home directory is read from the context variable "PULI_HOME".
  * If this variable is not set, the home directory defaults to:
  *
  *  * `$HOME/.puli` on Linux, where `$HOME` is the context variable
  *    "HOME".
  *  * `$APPDATA/Puli` on Windows, where `$APPDATA` is the context
  *    variable "APPDATA".
  *
  * If none of these variables can be found, an exception is thrown.
  *
  * A .htaccess file is put into the home directory to protect it from web
  * access.
  *
  * @param string $rootDir The path to the project.
  *
  * @return ProjectContext The project context.
  */
 private function createProjectContext($rootDir, $env)
 {
     Assert::fileExists($rootDir, 'Could not load Puli context: The root %s does not exist.');
     Assert::directory($rootDir, 'Could not load Puli context: The root %s is a file. Expected a directory.');
     $baseConfig = new DefaultConfig();
     $homeDir = self::parseHomeDirectory();
     if (null !== ($configFile = $this->loadConfigFile($homeDir, $baseConfig))) {
         $baseConfig = $configFile->getConfig();
     }
     // Create a storage without the factory manager
     $moduleFileStorage = new ModuleFileStorage($this->getStorage(), $this->getLegacyModuleFileConverter(), $this->getLegacyRootModuleFileConverter(), $this->getJsonEncoder(), $this->getJsonDecoder());
     $rootDir = Path::canonicalize($rootDir);
     $rootFilePath = $this->rootDir . '/puli.json';
     try {
         $rootModuleFile = $moduleFileStorage->loadRootModuleFile($rootFilePath, $baseConfig);
     } catch (FileNotFoundException $e) {
         $rootModuleFile = new RootModuleFile(null, $rootFilePath, $baseConfig);
     }
     $config = new EnvConfig($rootModuleFile->getConfig());
     return new ProjectContext($homeDir, $rootDir, $config, $rootModuleFile, $configFile, $this->dispatcher, $env);
 }
Пример #11
0
 protected function addJsonToRootModuleFile(stdClass $jsonData, RootModuleFile $moduleFile)
 {
     if (isset($jsonData->order)) {
         $moduleFile->setModuleOrder((array) $jsonData->order);
     }
     if (isset($jsonData->plugins)) {
         $moduleFile->setPluginClasses($jsonData->plugins);
     }
     if (isset($jsonData->config)) {
         $config = $moduleFile->getConfig();
         foreach ($this->objectsToArrays($jsonData->config) as $key => $value) {
             $config->set($key, $value);
         }
     }
     if (isset($jsonData->modules)) {
         foreach ($jsonData->modules as $moduleName => $moduleData) {
             $installInfo = new InstallInfo($moduleName, $moduleData->{'install-path'});
             if (isset($moduleData->env)) {
                 $installInfo->setEnvironment($moduleData->env);
             }
             if (isset($moduleData->installer)) {
                 $installInfo->setInstallerName($moduleData->installer);
             }
             if (isset($moduleData->{'disabled-bindings'})) {
                 foreach ($moduleData->{'disabled-bindings'} as $uuid) {
                     $installInfo->addDisabledBindingUuid(Uuid::fromString($uuid));
                 }
             }
             $moduleFile->addInstallInfo($installInfo);
         }
     }
 }