From b33d29e200f4776020e5ba8c4655616abe16cc70 Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Mon, 27 Nov 2023 10:05:52 +0100 Subject: [PATCH] Move secret under node webhook in configuration (#157) --- config/services.xml | 2 +- src/DependencyInjection/Configuration.php | 6 +++++- src/DependencyInjection/WebgriffeSyliusAkeneoExtension.php | 6 +++--- .../config/packages/webgriffe_sylius_akeneo_plugin.yaml | 7 ++++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/config/services.xml b/config/services.xml index 95487cc2..42309ff6 100644 --- a/config/services.xml +++ b/config/services.xml @@ -65,7 +65,7 @@ - %webgriffe_sylius_akeneo.webhook_secret% + %webgriffe_sylius_akeneo.webhook.secret% diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 8d0d32d8..4562a04a 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -33,7 +33,11 @@ public function getConfigTreeBuilder(): TreeBuilder ->end() ->end() - ->scalarNode('webhook_secret') + ->arrayNode('webhook') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('secret')->isRequired()->cannotBeEmpty()->defaultNull()->end() + ->end() ->end() ->arrayNode('value_handlers') diff --git a/src/DependencyInjection/WebgriffeSyliusAkeneoExtension.php b/src/DependencyInjection/WebgriffeSyliusAkeneoExtension.php index 057f940a..d8d657e7 100644 --- a/src/DependencyInjection/WebgriffeSyliusAkeneoExtension.php +++ b/src/DependencyInjection/WebgriffeSyliusAkeneoExtension.php @@ -122,7 +122,7 @@ public function load(array $configs, ContainerBuilder $container): void $this->registerResources('webgriffe_sylius_akeneo', 'doctrine/orm', $config['resources'], $container); $this->registerApiClientParameters($config['api_client'], $container); - $this->registerWebhookParameters($config['webhook_secret'], $container); + $this->registerWebhookParameters($config['webhook'], $container); $loader->load('services.xml'); @@ -254,8 +254,8 @@ private function registerTemporaryDirectoryParameter(ContainerBuilder $container $container->setParameter($parameterKey, sys_get_temp_dir()); } - private function registerWebhookParameters(string $webhookSecret, ContainerBuilder $container): void + private function registerWebhookParameters(array $webhook, ContainerBuilder $container): void { - $container->setParameter('webgriffe_sylius_akeneo.webhook_secret', $webhookSecret); + $container->setParameter('webgriffe_sylius_akeneo.webhook.secret', $webhook['secret']); } } diff --git a/tests/Application/config/packages/webgriffe_sylius_akeneo_plugin.yaml b/tests/Application/config/packages/webgriffe_sylius_akeneo_plugin.yaml index 8e8a35e4..d0cd4fd5 100644 --- a/tests/Application/config/packages/webgriffe_sylius_akeneo_plugin.yaml +++ b/tests/Application/config/packages/webgriffe_sylius_akeneo_plugin.yaml @@ -8,9 +8,10 @@ webgriffe_sylius_akeneo: password: '%env(WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_PASSWORD)%' client_id: '%env(WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_CLIENT_ID)%' secret: '%env(WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_SECRET)%' - - webhook_secret: '%env(WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_WEBHOOK_SECRET)%' - + + webhook: + secret: '%env(WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_WEBHOOK_SECRET)%' + value_handlers: product: attribute: