1 | <?php |
||
11 | class DtcQueueExtension extends Extension |
||
12 | { |
||
13 | 1 | public function load(array $configs, ContainerBuilder $container) |
|
14 | { |
||
15 | 1 | $processor = new Processor(); |
|
16 | 1 | $configuration = new Configuration(); |
|
17 | |||
18 | 1 | $config = $processor->processConfiguration($configuration, $configs); |
|
19 | |||
20 | 1 | if (isset($config['beanstalkd'])) { |
|
21 | if (!isset($config['beanstalkd']['host'])) { |
||
22 | throw new \Exception('dtc_queue: beanstalkd requires host in config.yml'); |
||
23 | } |
||
24 | } |
||
25 | |||
26 | 1 | if (isset($config['beanstalkd']['host'])) { |
|
27 | $container->setParameter('dtc_queue.beanstalkd.host', $config['beanstalkd']['host']); |
||
28 | } |
||
29 | 1 | if (isset($config['beanstalkd']['tube'])) { |
|
30 | $container->setParameter('dtc_queue.beanstalkd.tube', $config['beanstalkd']['tube']); |
||
31 | } |
||
32 | |||
33 | 1 | if (isset($config['rabbit_mq'])) { |
|
34 | foreach (['host', 'port', 'user', 'password'] as $value) { |
||
35 | if (!isset($config['rabbit_mq'][$value])) { |
||
36 | throw new \Exception('dtc_queue: rabbit_mq must have '.$value.' in config.yml'); |
||
37 | } |
||
38 | } |
||
39 | $container->setParameter('dtc_queue.rabbit_mq', $config['rabbit_mq']); |
||
40 | } |
||
41 | |||
42 | 1 | $container->setParameter('dtc_queue.default_manager', $config['default_manager']); |
|
43 | 1 | $container->setParameter('dtc_queue.document_manager', $config['document_manager']); |
|
44 | 1 | $container->setParameter('dtc_queue.entity_manager', $config['entity_manager']); |
|
45 | 1 | $container->setParameter('dtc_queue.class_job', isset($config['class_job']) ? $config['class_job'] : null); |
|
46 | 1 | $container->setParameter('dtc_queue.class_job_archive', isset($config['class_job_archive']) ? $config['class_job_archive'] : null); |
|
47 | 1 | $container->setParameter('dtc_queue.class_run', isset($config['class_run']) ? $config['class_run'] : null); |
|
48 | 1 | $container->setParameter('dtc_queue.class_run_archive', isset($config['class_run_archive']) ? $config['class_run_archive'] : null); |
|
49 | |||
50 | // Load Grid if Dtc\GridBundle Bundle is registered |
||
51 | 1 | $yamlLoader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
52 | |||
53 | 1 | $yamlLoader->load('queue.yml'); |
|
54 | 1 | } |
|
55 | |||
56 | public function getAlias() |
||
60 | } |
||
61 |