From 25600c14d2198388d354582026a0593f321e59d9 Mon Sep 17 00:00:00 2001 From: Victor Svizev Date: Thu, 9 Nov 2023 21:10:44 +0100 Subject: [PATCH 1/2] PAC-813 Add custom configuration public directory --- src/Command/AbstractImportCommand.php | 1 + src/Command/AbstractSimpleImportCommand.php | 1 + src/Command/InputOptionKeys.php | 1 + src/Configuration/LibraryLoader.php | 10 ++++++++++ src/SimpleConfigurationLoader.php | 14 ++++++++++++++ symfony/Resources/config/services.xml | 1 + symfony/Utils/DependencyInjectionKeys.php | 7 +++++++ 7 files changed, 35 insertions(+) diff --git a/src/Command/AbstractImportCommand.php b/src/Command/AbstractImportCommand.php index 667cbfa..2aa351b 100644 --- a/src/Command/AbstractImportCommand.php +++ b/src/Command/AbstractImportCommand.php @@ -56,6 +56,7 @@ protected function configure() ->addOption(InputOptionKeysInterface::MAGENTO_VERSION, null, InputOption::VALUE_REQUIRED, 'The Magento version to be used, e. g. "2.1.2"') ->addOption(InputOptionKeysInterface::CONFIGURATION, null, InputOption::VALUE_REQUIRED, 'Specify the pathname to the configuration file to use') ->addOption(InputOptionKeysInterface::CUSTOM_CONFIGURATION_DIR, null, InputOption::VALUE_REQUIRED, 'The path to the custom configuration directory') + ->addOption(InputOptionKeysInterface::CUSTOM_CONFIGURATION_PUBLIC_DIR, null, InputOption::VALUE_OPTIONAL, 'The path to the custom configuration public directory') ->addOption(InputOptionKeysInterface::SOURCE_DIR, null, InputOption::VALUE_REQUIRED, 'The directory that has to be watched for new files') ->addOption(InputOptionKeysInterface::TARGET_DIR, null, InputOption::VALUE_REQUIRED, 'The target directory with the files that has been imported') ->addOption(InputOptionKeysInterface::ARCHIVE_DIR, null, InputOption::VALUE_REQUIRED, 'The directory the imported files will be archived in') diff --git a/src/Command/AbstractSimpleImportCommand.php b/src/Command/AbstractSimpleImportCommand.php index 0f51edd..9c2f4fc 100644 --- a/src/Command/AbstractSimpleImportCommand.php +++ b/src/Command/AbstractSimpleImportCommand.php @@ -59,6 +59,7 @@ protected function configure() ->addOption(InputOptionKeysInterface::MAGENTO_EDITION, null, InputOption::VALUE_REQUIRED, 'The Magento edition to be used, either one of "CE" or "EE"', 'CE') ->addOption(InputOptionKeysInterface::CONFIGURATION, null, InputOption::VALUE_REQUIRED, 'Specify the pathname to the configuration file to use') ->addOption(InputOptionKeysInterface::CUSTOM_CONFIGURATION_DIR, null, InputOption::VALUE_REQUIRED, 'The path to the custom configuration directory') + ->addOption(InputOptionKeysInterface::CUSTOM_CONFIGURATION_PUBLIC_DIR, null, InputOption::VALUE_OPTIONAL, 'The path to the custom configuration public directory') ->addOption(InputOptionKeysInterface::LOG_LEVEL, null, InputOption::VALUE_REQUIRED, 'The log level to use') ->addOption(InputOptionKeysInterface::LOG_FILE, null, InputOption::VALUE_REQUIRED, 'The log file to use'); } diff --git a/src/Command/InputOptionKeys.php b/src/Command/InputOptionKeys.php index ef24243..eeb5622 100644 --- a/src/Command/InputOptionKeys.php +++ b/src/Command/InputOptionKeys.php @@ -67,6 +67,7 @@ public function __construct(array $inputOptionKeys = array()) InputOptionKeysInterface::CACHE_ENABLED, InputOptionKeysInterface::MOVE_FILES_PREFIX, InputOptionKeysInterface::CUSTOM_CONFIGURATION_DIR, + InputOptionKeysInterface::CUSTOM_CONFIGURATION_PUBLIC_DIR, InputOptionKeysInterface::RENDER_VALIDATION_ISSUES, InputOptionKeysInterface::EMPTY_ATTRIBUTE_VALUE_CONSTANT, InputOptionKeysInterface::STRICT_MODE, diff --git a/src/Configuration/LibraryLoader.php b/src/Configuration/LibraryLoader.php index f5e8d16..cf3cefa 100644 --- a/src/Configuration/LibraryLoader.php +++ b/src/Configuration/LibraryLoader.php @@ -80,6 +80,16 @@ protected function getCustomConfigurationDir() return $this->getContainer()->getParameter(DependencyInjectionKeys::APPLICATION_CUSTOM_CONFIGURATION_DIR); } + /** + * Return's the relative path to the custom configuration public directory. + * + * @return string The relative path to the custom configuration public directory + */ + protected function getCustomConfigurationPublicDir() + { + return $this->getContainer()->getParameter(DependencyInjectionKeys::APPLICATION_CUSTOM_CONFIGURATION_PUBLIC_DIR); + } + /** * Load's the external libraries registered in the passed configuration. * diff --git a/src/SimpleConfigurationLoader.php b/src/SimpleConfigurationLoader.php index 92f8b4a..f69b3ea 100644 --- a/src/SimpleConfigurationLoader.php +++ b/src/SimpleConfigurationLoader.php @@ -308,6 +308,15 @@ protected function createConfiguration($filename = null) ) ); + // initialize the default custom configuration directory + $customConfigurationPublicDir = implode( + DIRECTORY_SEPARATOR, + array_merge( + [$installationDir], + explode('/', $this->getContainer()->getParameter(DependencyInjectionKeys::APPLICATION_CUSTOM_CONFIGURATION_PUBLIC_DIR)) + ) + ); + // query whether or not a custom configuration directory has been speified, if yes override the default one if ($this->input->hasOptionSpecified(InputOptionKeysInterface::CUSTOM_CONFIGURATION_DIR) && $this->input->getOption(InputOptionKeysInterface::CUSTOM_CONFIGURATION_DIR)) { $customConfigurationDir = $this->input->getOption(InputOptionKeysInterface::CUSTOM_CONFIGURATION_DIR); @@ -318,6 +327,11 @@ protected function createConfiguration($filename = null) $directories[] = $customConfigurationDir; } + // specify the default directory for custom configuration public files + if (is_dir($customConfigurationPublicDir)) { + $directories[] = $customConfigurationPublicDir; + } + // load and return the configuration from the files found in the passed directories $completeConfiguration = $this->configurationFactory->factoryFromDirectories($installationDir, $defaultConfigurationDir, $directories, $format, $params, $paramsFile); diff --git a/symfony/Resources/config/services.xml b/symfony/Resources/config/services.xml index e7cfdb1..28ca3fc 100644 --- a/symfony/Resources/config/services.xml +++ b/symfony/Resources/config/services.xml @@ -9,6 +9,7 @@ .semver etc app/etc + var/pacemaker/import TechDivision\Import\Utils\EditionNamesInterface::CE TechDivision\Import\Utils\EditionNamesInterface::EE diff --git a/symfony/Utils/DependencyInjectionKeys.php b/symfony/Utils/DependencyInjectionKeys.php index 2f5f358..8174fee 100644 --- a/symfony/Utils/DependencyInjectionKeys.php +++ b/symfony/Utils/DependencyInjectionKeys.php @@ -123,4 +123,11 @@ class DependencyInjectionKeys extends \TechDivision\Import\App\Utils\DependencyI * @var string */ const APPLICATION_CUSTOM_CONFIGURATION_DIR = 'application.custom.configuration.dir'; + + /** + * The key for the DI parameter that contains the custom configuration public directory. + * + * @var string + */ + const APPLICATION_CUSTOM_CONFIGURATION_PUBLIC_DIR = 'application.custom.configuration.public.dir'; } From 9b36120adde95081cba3d6f58459a9907ce0bf58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Eisenfu=CC=88hrer?= Date: Tue, 14 Nov 2023 11:42:55 +0100 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8182366..9215095 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Version 12.5.0 + +## Feature + +* Preparation of a customer path for Magento backend storage of the configuration in `var/pacemaker/import/configuration` + + # Version 12.4.0 ## Bugfixes