|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright 2012 Johannes M. Schmitt <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace JMS\JobQueueBundle\DependencyInjection; |
|
20
|
|
|
|
|
21
|
|
|
use JMS\JobQueueBundle\Console\CronCommand; |
|
22
|
|
|
use JMS\JobQueueBundle\Cron\JobScheduler; |
|
23
|
|
|
use JMS\JobQueueBundle\Entity\Type\SafeObjectType; |
|
24
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
25
|
|
|
use Symfony\Component\Config\FileLocator; |
|
26
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
27
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
28
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* This is the class that loads and manages your bundle configuration |
|
32
|
|
|
* |
|
33
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
|
34
|
|
|
*/ |
|
35
|
|
|
class JMSJobQueueExtension extends Extension implements PrependExtensionInterface |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* {@inheritDoc} |
|
39
|
|
|
*/ |
|
40
|
6 |
|
public function load(array $configs, ContainerBuilder $container) |
|
41
|
|
|
{ |
|
42
|
6 |
|
$configuration = new Configuration(); |
|
43
|
6 |
|
$config = $this->processConfiguration($configuration, $configs); |
|
44
|
|
|
|
|
45
|
6 |
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
46
|
6 |
|
$loader->load('services.xml'); |
|
47
|
6 |
|
$loader->load('console.xml'); |
|
48
|
|
|
|
|
49
|
6 |
|
$container->setParameter('jms_job_queue.statistics', $config['statistics']); |
|
50
|
6 |
|
if ($config['statistics']) { |
|
51
|
6 |
|
$loader->load('statistics.xml'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
6 |
|
$container->registerForAutoconfiguration(JobScheduler::class) |
|
55
|
6 |
|
->addTag('jms_job_queue.scheduler'); |
|
56
|
6 |
|
$container->registerForAutoconfiguration(CronCommand::class) |
|
57
|
6 |
|
->addTag('jms_job_queue.cron_command'); |
|
58
|
|
|
|
|
59
|
6 |
|
$container->setParameter('jms_job_queue.queue_options_defaults', $config['queue_options_defaults']); |
|
60
|
6 |
|
$container->setParameter('jms_job_queue.queue_options', $config['queue_options']); |
|
61
|
6 |
|
} |
|
62
|
|
|
|
|
63
|
6 |
|
public function prepend(ContainerBuilder $container) |
|
64
|
|
|
{ |
|
65
|
6 |
|
$container->prependExtensionConfig('doctrine', array( |
|
66
|
|
|
'dbal' => array( |
|
67
|
|
|
'types' => array( |
|
68
|
|
|
'jms_job_safe_object' => array( |
|
69
|
6 |
|
'class' => SafeObjectType::class, |
|
70
|
|
|
'commented' => true, |
|
71
|
|
|
) |
|
72
|
|
|
) |
|
73
|
|
|
) |
|
74
|
|
|
)); |
|
75
|
6 |
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|