1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the MindbazBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) David DELEVOYE <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Kozikaza\MindbazBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
17
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* This is the class that loads and manages your bundle configuration |
21
|
|
|
* |
22
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
23
|
|
|
* |
24
|
|
|
* @author Vincent Chalamon <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class MindbazExtension extends Extension |
27
|
|
|
{ |
28
|
|
|
private $classes = []; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Gets the classes to cache. |
32
|
|
|
* |
33
|
|
|
* @return array An array of classes |
34
|
|
|
*/ |
35
|
|
|
public function getClassesToCompile() |
36
|
|
|
{ |
37
|
|
|
return $this->classes; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Adds classes to the class cache. |
42
|
|
|
* |
43
|
|
|
* @param array $classes An array of classes |
44
|
|
|
*/ |
45
|
|
|
public function addClassesToCompile(array $classes) |
46
|
|
|
{ |
47
|
|
|
$this->classes = array_merge($this->classes, $classes); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritDoc} |
52
|
|
|
*/ |
53
|
|
|
public function load(array $configs, ContainerBuilder $container) |
54
|
|
|
{ |
55
|
|
|
$configuration = new Configuration(); |
56
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
57
|
|
|
|
58
|
|
|
$container->setParameter('mindbaz.credentials', $config['credentials']); |
59
|
|
|
$container->setParameter('mindbaz.campaigns', $config['campaigns']); |
60
|
|
|
$container->setParameter('mindbaz.insertMissingSubscribers', $config['insertMissingSubscribers']); |
61
|
|
|
|
62
|
|
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
63
|
|
|
$loader->load('mailer.xml'); |
64
|
|
|
|
65
|
|
|
if (array_key_exists('JMSSerializerBundle', $container->getParameter('kernel.bundles'))) { |
66
|
|
|
$loader->load('jmsserializer.xml'); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|