123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- declare(strict_types=1);
- namespace Magento\Config\Setup;
- use Magento\Framework\App\DeploymentConfig;
- use Magento\Framework\Config\Data\ConfigData;
- use Magento\Framework\Config\Data\ConfigDataFactory;
- use Magento\Framework\Config\File\ConfigFilePool;
- use Magento\Framework\Setup\ConfigOptionsListInterface;
- use Magento\Framework\Setup\Option\SelectConfigOption;
- /**
- * Deployment configuration options required for the Config module.
- */
- class ConfigOptionsList implements ConfigOptionsListInterface
- {
- /**
- * Input key for the debug_logging option.
- */
- const INPUT_KEY_DEBUG_LOGGING = 'enable-debug-logging';
- /**
- * Path to the debug_logging value in the deployment config.
- */
- const CONFIG_PATH_DEBUG_LOGGING = 'dev/debug/debug_logging';
- /**
- * Input key for the syslog_logging option.
- */
- const INPUT_KEY_SYSLOG_LOGGING = 'enable-syslog-logging';
- /**
- * Path to the syslog_logging value in the deployment config.
- */
- const CONFIG_PATH_SYSLOG_LOGGING = 'dev/syslog/syslog_logging';
- /**
- * @var ConfigDataFactory
- */
- private $configDataFactory;
- /**
- * @param ConfigDataFactory $configDataFactory
- */
- public function __construct(ConfigDataFactory $configDataFactory)
- {
- $this->configDataFactory = $configDataFactory;
- }
- /**
- * @inheritdoc
- */
- public function getOptions()
- {
- return [
- new SelectConfigOption(
- self::INPUT_KEY_DEBUG_LOGGING,
- SelectConfigOption::FRONTEND_WIZARD_RADIO,
- [true, false, 1, 0],
- self::CONFIG_PATH_DEBUG_LOGGING,
- 'Enable debug logging'
- ),
- new SelectConfigOption(
- self::INPUT_KEY_SYSLOG_LOGGING,
- SelectConfigOption::FRONTEND_WIZARD_RADIO,
- [true, false, 1, 0],
- self::CONFIG_PATH_SYSLOG_LOGGING,
- 'Enable syslog logging'
- ),
- ];
- }
- /**
- * @inheritdoc
- */
- public function createConfig(array $options, DeploymentConfig $deploymentConfig)
- {
- $deploymentOption = [
- self::INPUT_KEY_DEBUG_LOGGING => self::CONFIG_PATH_DEBUG_LOGGING,
- self::INPUT_KEY_SYSLOG_LOGGING => self::CONFIG_PATH_SYSLOG_LOGGING,
- ];
- $config = [];
- foreach ($deploymentOption as $inputKey => $configPath) {
- $configValue = $this->processBooleanConfigValue(
- $inputKey,
- $configPath,
- $options
- );
- if ($configValue) {
- $config[] = $configValue;
- }
- }
- return $config;
- }
- /**
- * Provide config value from input.
- *
- * @param string $inputKey
- * @param string $configPath
- * @param array $options
- * @return ConfigData|null
- */
- private function processBooleanConfigValue(string $inputKey, string $configPath, array &$options): ?ConfigData
- {
- $configData = null;
- if (isset($options[$inputKey])) {
- $configData = $this->configDataFactory->create(ConfigFilePool::APP_ENV);
- if ($options[$inputKey] === 'true'
- || $options[$inputKey] === '1') {
- $value = 1;
- } else {
- $value = 0;
- }
- $configData->set($configPath, $value);
- }
- return $configData;
- }
- /**
- * @inheritdoc
- */
- public function validate(array $options, DeploymentConfig $deploymentConfig)
- {
- return [];
- }
- }
|