private function loadInstallers(Module $module) { foreach (self::$builtinInstallers as $name => $installerData) { $installer = $this->dataToInstaller($name, (object) $installerData); $this->installerDescriptors[$name] = $installer; } $moduleFile = $module->getModuleFile(); if (null === $moduleFile) { return; } $moduleName = $module->getName(); $installersData = $moduleFile->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 module \"%s\" is invalid:\n%s", self::INSTALLERS_KEY, $moduleName, implode("\n", $errors))); } foreach ($installersData as $name => $installerData) { $installer = $this->dataToInstaller($name, $installerData); $this->installerDescriptors[$name] = $installer; if ($module instanceof RootModule) { $this->rootInstallerDescriptors[$name] = $installer; } } }
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())); }