/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $inputOptions = $input->getOptions(); $optionCollection = $this->configModel->getAvailableOptions(); $commandOptions = []; $optionsWithDefaultValues = []; foreach ($optionCollection as $option) { $commandOptions[$option->getName()] = false; $currentValue = $this->deploymentConfig->get($option->getConfigPath()); if ($currentValue !== null && $inputOptions[$option->getName()] !== null) { $dialog = $this->getHelperSet()->get('dialog'); if (!$dialog->askConfirmation($output, '<question>Overwrite the existing configuration for ' . $option->getName() . '?[Y/n]</question>')) { $inputOptions[$option->getName()] = null; } } if ($option->getDefault() === $inputOptions[$option->getName()] && $inputOptions[$option->getName()] !== null) { $optionsWithDefaultValues[] = $option->getName(); } } $inputOptions = array_filter($inputOptions, function ($value) { return $value !== null; }); $optionsToChange = array_intersect(array_keys($inputOptions), array_keys($commandOptions)); $this->configModel->process($inputOptions); if (count($optionsWithDefaultValues) > 0) { $defaultValuesMessage = implode(', ', $optionsWithDefaultValues); $output->writeln('<info>We saved default values for these options: ' . $defaultValuesMessage . '.</info>'); } else { if (count($optionsToChange) > 0) { $output->writeln('<info>You saved the new configuration.</info>'); } else { $output->writeln('<info>You made no changes to the configuration.</info>'); } } }
/** * @expectedException \Exception * @expectedExceptionMessage Missing write permissions to the following paths: */ public function testWritePermissionErrors() { $this->filePermissions->expects($this->once())->method('getMissingWritablePathsForInstallation')->willReturn(['/a/ro/dir', '/media']); $this->configModel->process([]); }
/** * Installs deployment configuration * * @param \ArrayObject|array $data * @return void */ public function installDeploymentConfig($data) { $this->checkInstallationFilePermissions(); $this->createModulesConfig($data); $userData = is_array($data) ? $data : $data->getArrayCopy(); $this->setupConfigModel->process($userData); if ($this->deploymentConfig->isAvailable()) { $deploymentConfigData = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY); if (isset($deploymentConfigData)) { $this->installInfo[ConfigOptionsListConstants::KEY_ENCRYPTION_KEY] = $deploymentConfigData; } } // reset object manager now that there is a deployment config $this->objectManagerProvider->reset(); }