|
1
|
|
|
<?php |
|
2
|
|
|
namespace Azine\MailgunWebhooksBundle\DependencyInjection; |
|
3
|
|
|
|
|
4
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
|
6
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* This is the class that loads and manages your bundle configuration |
|
11
|
|
|
* |
|
12
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
|
13
|
|
|
*/ |
|
14
|
|
|
class AzineMailgunWebhooksExtension extends Extension |
|
15
|
|
|
{ |
|
16
|
|
|
const PREFIX = "azine_mailgun_webhooks"; |
|
17
|
|
|
const API_KEY = "api_key"; |
|
18
|
|
|
const PUBLIC_API_KEY = "public_api_key"; |
|
19
|
|
|
const EMAIL_DOMAIN = "email_domain"; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* {@inheritDoc} |
|
23
|
|
|
*/ |
|
24
|
3 |
|
public function load(array $configs, ContainerBuilder $container) |
|
25
|
|
|
{ |
|
26
|
3 |
|
$configuration = new Configuration(); |
|
27
|
3 |
|
$config = $this->processConfiguration($configuration, $configs); |
|
28
|
|
|
|
|
29
|
2 |
View Code Duplication |
if(array_key_exists(self::API_KEY, $config)) |
|
30
|
2 |
|
$container->setParameter(self::PREFIX."_".self::API_KEY, $config[self::API_KEY]); |
|
31
|
|
|
|
|
32
|
2 |
View Code Duplication |
if(array_key_exists(self::PUBLIC_API_KEY, $config)) |
|
33
|
2 |
|
$container->setParameter(self::PREFIX."_".self::PUBLIC_API_KEY, $config[self::PUBLIC_API_KEY]); |
|
34
|
|
|
|
|
35
|
2 |
View Code Duplication |
if(array_key_exists(self::EMAIL_DOMAIN, $config)) |
|
36
|
2 |
|
$container->setParameter(self::PREFIX."_".self::EMAIL_DOMAIN, $config[self::EMAIL_DOMAIN]); |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
2 |
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
40
|
2 |
|
$loader->load('services.yml'); |
|
41
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|