1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Gearman Bundle for Symfony2 / Symfony3 |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* Feel free to edit as you please, and have fun. |
10
|
|
|
* |
11
|
|
|
* @author Marc Morera <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Mkk\GearmanBundle\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Config\FileLocator; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
19
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* This is the class that loads and manages your bundle configuration |
23
|
|
|
*/ |
24
|
|
|
class GearmanExtension extends Extension |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Loads a specific configuration. |
28
|
|
|
* |
29
|
|
|
* @param array $config An array of configuration values |
30
|
|
|
* @param ContainerBuilder $container A ContainerBuilder instance |
31
|
|
|
* |
32
|
|
|
* @throws \InvalidArgumentException When provided tag is not defined in this extension |
33
|
|
|
* |
34
|
|
|
* @api |
35
|
|
|
*/ |
36
|
1 |
|
public function load(array $config, ContainerBuilder $container) |
37
|
|
|
{ |
38
|
1 |
|
$configuration = new Configuration(); |
39
|
1 |
|
$config = $this->processConfiguration($configuration, $config); |
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Setting all config elements as DI parameters to inject them |
43
|
|
|
*/ |
44
|
1 |
|
$container->setParameter( |
45
|
1 |
|
'gearman.bundles', |
46
|
1 |
|
$config['bundles'] |
47
|
|
|
); |
48
|
|
|
|
49
|
1 |
|
$container->setParameter( |
50
|
1 |
|
'gearman.resources', |
51
|
1 |
|
$config['resources'] |
52
|
|
|
); |
53
|
|
|
|
54
|
1 |
|
$container->setParameter( |
55
|
1 |
|
'gearman.servers', |
56
|
1 |
|
$config['servers'] |
57
|
|
|
); |
58
|
|
|
|
59
|
1 |
|
$container->setParameter( |
60
|
1 |
|
'gearman.default.settings', |
61
|
1 |
|
$config['defaults'] |
62
|
|
|
); |
63
|
|
|
|
64
|
1 |
|
$container->setParameter( |
65
|
1 |
|
'gearman.default.settings.generate_unique_key', |
66
|
1 |
|
$config['defaults']['generate_unique_key'] |
67
|
|
|
); |
68
|
|
|
|
69
|
1 |
|
$loader = new YamlFileLoader( |
70
|
1 |
|
$container, |
71
|
1 |
|
new FileLocator(__DIR__ . '/../Resources/config') |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Loading DI definitions |
76
|
|
|
*/ |
77
|
1 |
|
$loader->load('classes.yml'); |
78
|
1 |
|
$loader->load('services.yml'); |
79
|
1 |
|
$loader->load('commands.yml'); |
80
|
1 |
|
$loader->load('eventDispatchers.yml'); |
81
|
1 |
|
$loader->load('generators.yml'); |
82
|
1 |
|
$loader->load('externals.yml'); |
83
|
1 |
|
} |
84
|
|
|
} |
85
|
|
|
|