6 declare(strict_types=1);
10 use Composer\IO\IOInterface;
19 private $deploymentConfig;
24 private $deploymentConfigWriter;
37 $this->deploymentConfigWriter = $deploymentConfigWriter;
43 if ($this->isModuleAlreadyConfigured($moduleName)) {
44 $this->doNotChangeConfiguredValue($moduleName);
48 $this->disableModule($moduleName);
51 private function isModuleAlreadyConfigured(
string $moduleName): bool
53 $configValue = $this->getModuleConfigurationValue($moduleName);
54 return null !== $configValue;
57 private function doNotChangeConfiguredValue($moduleName): void
59 $configValue = $this->getModuleConfigurationValue($moduleName);
60 if (
null === $configValue) {
61 $moduleStatus =
'undefined';
63 $moduleStatus =
'enabled';
65 $moduleStatus =
'disabled';
68 $this->io->writeError(sprintf(
69 ' ...Keep %s module %s as in current configuration',
75 private function disableModule($moduleName): void
77 $this->io->writeError(sprintf(
78 ' ...Disabling %s module for backward compatibility',
82 $this->deploymentConfigWriter->saveConfig([
91 private function getModuleConfigurationValue(
string $moduleName): ?bool
93 $configKey =
'modules/' . $moduleName;
94 $configValue = $this->deploymentConfig->get($configKey);
95 return isset($configValue) ? (bool)$configValue :
null;
configure(string $moduleName)
elseif(isset( $params[ 'redirect_parent']))
__construct(DeploymentConfig $deploymentConfig, DeploymentConfig\Writer $deploymentConfigWriter, IOInterface $io)