Skip to content
This repository was archived by the owner on May 18, 2020. It is now read-only.

Commit d3a7de3

Browse files
committed
API-20: Bundle parameter defined in configuration file
1 parent 8109d18 commit d3a7de3

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public function getConfigTreeBuilder()
2323
// Here you should define the parameters that are allowed to
2424
// configure your bundle. See the documentation linked above for
2525
// more information on that topic.
26+
$rootNode->children()
27+
->scalarNode('api_key')->isRequired()->cannotBeEmpty()->end()
28+
->end();
2629

2730
return $treeBuilder;
2831
}

DependencyInjection/SendinBlueApiExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ public function load(array $configs, ContainerBuilder $container)
2424

2525
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
2626
$loader->load('services.yml');
27+
$container->setParameter('sendin_blue_api.config',$config);
2728
}
2829
}

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ public function registerBundles()
5555

5656
### Add SendinBlue Api key
5757

58-
In your `app/config/parameters.yml`:
58+
In your `app/config/config.yml`:
5959

6060
```yaml
61-
sendinblue_api_key: <Your access key>
61+
sendin_blue_api:
62+
api_key: <Your access key>
6263
```
6364
6465

Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ parameters:
44
services:
55
sendinblue_api:
66
class: %sendinblue_api.class%
7-
arguments: [%sendinblue_api_key%]
7+
arguments: [%sendin_blue_api.config%]

Wrapper/Mailin.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public function __construct($api_key)
2323
{
2424
throw new \RuntimeException('Mailin requires cURL module');
2525
}
26+
$this->config = $api_key;
2627
$this->base_url = "https://api.sendinblue.com/v2.0";
27-
$this->api_key = $api_key;
28+
$this->api_key = $this->config['api_key'];
2829
}
2930
/**
3031
* Do CURL request with authorization
@@ -945,4 +946,4 @@ public function send_bat_sms($data)
945946
}
946947

947948
}
948-
?>
949+
?>

0 commit comments

Comments
 (0)