Skip to content

Commit

Permalink
Improve: Add configuration storage locations to Symfony tree
Browse files Browse the repository at this point in the history
  • Loading branch information
robertSt7 committed Mar 30, 2023
1 parent 1d7afc0 commit f17ad8b
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/ci/files/.env.test

This file was deleted.

5 changes: 5 additions & 0 deletions .github/ci/files/config/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ pimcore_admin:
color_login_screen: ''
color_admin_interface: ''
login_screen_custom_image: ''
pimcore_data_hub:
config_location:
data_hub:
target: 'settings-store'

1 change: 0 additions & 1 deletion .github/ci/scripts/setup-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mkdir -p var/config
mkdir -p bin

cp .github/ci/files/.env .
cp .github/ci/files/.env.test .
cp -r .github/ci/files/config/. config
cp -r .github/ci/files/templates/. templates
cp -r .github/ci/files/bin/console bin/console
Expand Down
12 changes: 8 additions & 4 deletions doc/20_Deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ for specific definitions.
### Configuration Storage

The configuration user interface utilizes the `LocationAwareConfigRepository` for storing the configuration. With
the environment variable `PIMCORE_WRITE_TARGET_DATA_HUB` the storage location can be configured, possible values are
The configuration user interface utilizes the `LocationAwareConfigRepository` for storing the configuration. In the symfony tree the storage location can be configured, possible values are
- `symfony-config` - write configs as Symfony Config as YAML files to `/var/config/data-hub/<name>.yaml`
- `settings-store` - write configs to the SettingsStore
- `disabled` - do not allow to edit/write configs at all
Expand All @@ -40,8 +39,13 @@ won't see any update, because these configs are read only.
Details also see [Pimcore Docs](https://pimcore.com/docs/pimcore/current/Development_Documentation/Deployment/Configuration_Environments.html#page_Configuration-Storage-Locations-Fallbacks).

#### Example
```env
PIMCORE_WRITE_TARGET_DATA_HUB=symfony-config
```yaml
pimcore_data_hub:
config_location:
data_hub:
target: 'symfony-config'
options:
directory: '/var/www/html/var/config/data_hub'
```

Additionally, it is also possible to define the configuration directly in a symfony configuration file without using
Expand Down
13 changes: 9 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@ parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 3
count: 4
path: src/DependencyInjection/Configuration.php

-
message: "#Call to static method addConfigLocationWithWriteTargetNodes() on an unknown class#"
message: "#Call to static method addConfigLocationWithWriteTargetNodes\\(\\) on an unknown class\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php

-
message: "#Call to static method getConfigNodeFromSymfonyTree() on an unknown class#"
message: "#Call to static method getConfigNodeFromSymfonyTree\\(\\) on an unknown class\\.$#"
count: 1
path: src/DependencyInjection/PimcoreDataHubExtension.php

-
message: "#Call to static method getSymfonyConfigFiles() on an unknown class#"
message: "#Call to static method getSymfonyConfigFiles\\(\\) on an unknown class\\.$#"
count: 1
path: src/DependencyInjection/PimcoreDataHubExtension.php

-
message: "#Call to an undefined static method Pimcore\\\\Config\\\\LocationAwareConfigRepository\\:\\:getStorageConfigurationCompatibilityLayer\\(\\)\\.$#"
count: 1
path: src/Configuration/Dao.php

-
message: "#^Constructor of class Pimcore\\\\Bundle\\\\DataHubBundle\\\\GraphQL\\\\AssetType\\\\AssetFolderType has an unused parameter \\$config\\.$#"
count: 1
Expand Down
10 changes: 8 additions & 2 deletions src/Configuration/Dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ public function configure(): void
'storageConfig' => $storageConfig,
]);
} else {
$storageConfig = Config\LocationAwareConfigRepository::getStorageConfigurationCompatibilityLayer(
$config,
'data_hub',
'PIMCORE_CONFIG_STORAGE_DIR_DATA_HUB',
'PIMCORE_WRITE_TARGET_DATA_HUB'
);

parent::configure([
'containerConfig' => $config['configurations'] ?? [],
'settingsStoreScope' => 'pimcore_data_hub',
'storageDirectory' => self::CONFIG_PATH,
'storageDirectory' => $storageConfig,
'legacyConfigFile' => self::LEGACY_FILE,
'writeTargetEnvVariableName' => 'PIMCORE_WRITE_TARGET_DATA_HUB'
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/DatahubConfigLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Symfony\Component\Finder\Finder;

/**
* @deprecated will be removed in Pimcore 11
* @deprecated will be removed in Data-Hub 2.0
* Locates data hub configs
*/
class DatahubConfigLocator
Expand Down
21 changes: 21 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,28 @@ public function getConfigTreeBuilder()
$this->addSupportedTypes($rootNode);

if (\Pimcore\Version::getMajorVersion() >= 11) {
/** @var ArrayNodeDefinition $rootNode */
ConfigurationHelper::addConfigLocationWithWriteTargetNodes($rootNode, ['data_hub']);
} else {
$rootNode
->children()
->arrayNode('config_location')
->addDefaultsIfNotSet()
->children()
->arrayNode('data_hub')
->addDefaultsIfNotSet()
->children()
->enumNode('target')
->values(['symfony-config', 'settings-store'])
->defaultValue('symfony-config')
->end()
->arrayNode('options')
->defaultValue(['directory' => '%kernel.project_dir%data_hub'])
->variablePrototype()
->end()
->end()
->end()
->end();
}

return $treeBuilder;
Expand Down

0 comments on commit f17ad8b

Please sign in to comment.