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->jsonStorage->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())); }
private function saveRootModuleFile() { $this->jsonStorage->saveRootModuleFile($this->rootModuleFile); }
/** * {@inheritdoc} */ protected function saveConfigFile() { $this->jsonStorage->saveRootModuleFile($this->rootModuleFile); }
private function loadConfigFile($homeDir, Config $baseConfig) { if (null === $homeDir) { return null; } Assert::fileExists($homeDir, 'Could not load Puli context: The home directory %s does not exist.'); Assert::directory($homeDir, 'Could not load Puli context: The home directory %s is a file. Expected a directory.'); // Create a storage without the factory manager $jsonStorage = new JsonStorage($this->getStorage(), new JsonConverterProvider($this), $this->getJsonEncoder(), $this->getJsonDecoder()); $configPath = Path::canonicalize($homeDir) . '/config.json'; try { return $jsonStorage->loadConfigFile($configPath, $baseConfig); } catch (FileNotFoundException $e) { // It's ok if no config.json exists. We'll work with // DefaultConfig instead return null; } }
/** * {@inheritdoc} */ protected function saveConfigFile() { $this->jsonStorage->saveConfigFile($this->configFile); }