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