Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAC-813 Add custom configuration public directory #19

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions src/Command/AbstractImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions src/Command/AbstractSimpleImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
1 change: 1 addition & 0 deletions src/Command/InputOptionKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions src/Configuration/LibraryLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
14 changes: 14 additions & 0 deletions src/SimpleConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions symfony/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<parameter key="application.version.file">.semver</parameter>
<parameter key="application.default.configuration.dir">etc</parameter>
<parameter key="application.custom.configuration.dir">app/etc</parameter>
<parameter key="application.custom.configuration.public.dir">var/pacemaker/import</parameter>
<parameter key="application.edition.mappings" type="collection">
<parameter key="magento/product-community-edition" type="constant">TechDivision\Import\Utils\EditionNamesInterface::CE</parameter>
<parameter key="magento/product-enterprise-edition" type="constant">TechDivision\Import\Utils\EditionNamesInterface::EE</parameter>
Expand Down
7 changes: 7 additions & 0 deletions symfony/Utils/DependencyInjectionKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Loading