Browse code

Change configuration and define defaults

Benjamin Roth authored on18/10/2024 11:55:26
Showing4 changed files
1 1
deleted file mode 100644
... ...
@@ -1,5 +0,0 @@
1
-shopware_api:
2
-    credentials:
3
-        client_id: ''
4
-        client_secret: ''
5
-        api_endpoint: 'https://YOUR-SHOPWARE-DOMAIN/api'
... ...
@@ -19,7 +19,7 @@ class Configuration implements ConfigurationInterface
19 19
 {
20 20
     public function getConfigTreeBuilder(): TreeBuilder
21 21
     {
22
-        $treeBuilder = new TreeBuilder('shopware_api');
22
+        $treeBuilder = new TreeBuilder('vonrotenberg_shopware_api');
23 23
         $treeBuilder
24 24
             ->getRootNode()
25 25
             ->children()
... ...
@@ -28,12 +28,15 @@ class Configuration implements ConfigurationInterface
28 28
                     ->children()
29 29
                         ->scalarNode('client_id')
30 30
                             ->info('Your Shopware client ID.')
31
+                            ->defaultValue('')
31 32
                         ->end()
32
-                        ->scalarNode('client_id')
33
+                        ->scalarNode('client_secret')
33 34
                             ->info('Your Shopware client secret.')
35
+                            ->defaultValue('')
34 36
                         ->end()
35 37
                         ->scalarNode('api_endpoint')
36 38
                             ->info('The endpoint URL of your Shopware installation.')
39
+                            ->defaultValue('')
37 40
                         ->end()
38 41
                     ->end()
39 42
                 ->end()
40 43
new file mode 100644
... ...
@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
+
5
+/*
6
+ * This file is part of vonRotenberg Shopware API Bundle.
7
+ *
8
+ * (c) vonRotenberg
9
+ *
10
+ * @license proprietary
11
+ */
12
+
13
+namespace vonRotenberg\ShopwareApiBundle\DependencyInjection;
14
+
15
+use Symfony\Component\Config\FileLocator;
16
+use Symfony\Component\DependencyInjection\ContainerBuilder;
17
+use Symfony\Component\DependencyInjection\Extension\Extension;
18
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19
+
20
+class VonrotenbergShopwareApiExtension extends Extension
21
+{
22
+    public function load(array $configs, ContainerBuilder $container): void
23
+    {
24
+        $config = $this->processConfiguration(new Configuration(), $configs);
25
+
26
+        foreach($config['credentials'] as $key=>$val)
27
+        {
28
+            $container->setParameter('vonrotenberg_shopware_api.credentials.'.$key,$val);
29
+        }
30
+
31
+        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
32
+        $loader->load('services.yml');
33
+    }
34
+}
0 35
deleted file mode 100644
... ...
@@ -1,34 +0,0 @@
1
-<?php
2
-
3
-declare(strict_types=1);
4
-
5
-/*
6
- * This file is part of vonRotenberg Shopware API Bundle.
7
- *
8
- * (c) vonRotenberg
9
- *
10
- * @license proprietary
11
- */
12
-
13
-namespace vonRotenberg\ShopwareApiBundle\DependencyInjection;
14
-
15
-use Symfony\Component\Config\FileLocator;
16
-use Symfony\Component\DependencyInjection\ContainerBuilder;
17
-use Symfony\Component\DependencyInjection\Extension\Extension;
18
-use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19
-
20
-class VonrotenbergShopwareApiExtension extends Extension
21
-{
22
-    public function load(array $configs, ContainerBuilder $container): void
23
-    {
24
-        $config = $this->processConfiguration(new Configuration(), $configs);
25
-
26
-        foreach($config['credentials'] as $key=>$val)
27
-        {
28
-            $container->setParameter('shopware_api.credentials.'.$key,$val);
29
-        }
30
-
31
-        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
32
-        $loader->load('services.yml');
33
-    }
34
-}