DtcQueueExtension::getAlias()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Dtc\QueueBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Config...dConfigurationException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Symfony\Component\Config\Definition\Processor;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Config\Definition\Processor was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Symfony\Component\Config\FileLocator;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Config\FileLocator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...ection\ContainerBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Symfony\Component\DependencyInjection\Loader;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\DependencyInjection\Loader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKe...encyInjection\Extension was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
class DtcQueueExtension extends Extension
13
{
14 10
    public function load(array $configs, ContainerBuilder $container): void
15
    {
16 10
        $processor = new Processor();
17 10
        $configuration = new Configuration();
18
19 10
        $config = $processor->processConfiguration($configuration, $configs);
20 10
        $this->configBeanstalkd($config, $container);
21 10
        $this->configRabbitMQ($config, $container);
22 10
        $this->configRedis($config, $container);
23
24 10
        $container->setParameter('dtc_queue.locale_fix', $config['locale_fix']);
25 10
        $container->setParameter('dtc_queue.manager.job', $config['manager']['job']);
26 10
        $container->setParameter('dtc_queue.odm.document_manager', $config['odm']['document_manager']);
27 10
        $container->setParameter('dtc_queue.orm.entity_manager', $config['orm']['entity_manager']);
28 10
        $container->setParameter('dtc_queue.manager.run', isset($config['manager']['run']) ? $config['manager']['run'] : $config['manager']['job']);
29 10
        $container->setParameter('dtc_queue.manager.job_timing', isset($config['manager']['job_timing']) ? $config['manager']['job_timing'] : $container->getParameter('dtc_queue.manager.run'));
30 10
        $container->setParameter('dtc_queue.priority.direction', $config['priority']['direction']);
31 10
        $container->setParameter('dtc_queue.priority.max', $config['priority']['max']);
32 10
        $container->setParameter('dtc_queue.retry.max.retries', $config['retry']['max']['retries']);
33 10
        $container->setParameter('dtc_queue.retry.max.failures', $config['retry']['max']['failures']);
34 10
        $container->setParameter('dtc_queue.retry.max.exceptions', $config['retry']['max']['exceptions']);
35 10
        $container->setParameter('dtc_queue.retry.max.stalls', $config['retry']['max']['stalls']);
36 10
        $container->setParameter('dtc_queue.retry.auto.failure', $config['retry']['auto']['failure']);
37 10
        $container->setParameter('dtc_queue.retry.auto.exception', $config['retry']['auto']['exception']);
38 10
        $this->configClasses($config, $container);
39 10
        $this->configRecordTimings($config, $container);
40 10
        $this->configAdmin($config, $container);
41 10
        $this->configDeprecated($config, $container);
42
43
        // Load Grid if Dtc\GridBundle Bundle is registered
44 10
        $yamlLoader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...n\Loader\YamlFileLoader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
45
46 10
        $yamlLoader->load('queue.yml');
47 10
    }
48
49 10
    protected function configDeprecated(array $config, ContainerBuilder $container)
50
    {
51 10
        if (isset($config['default_manager'])) {
52 1
            $container->setParameter('dtc_queue.manager.job', $config['default_manager']);
53
        }
54 10
        if (isset($config['run_manager'])) {
55 1
            $container->setParameter('dtc_queue.manager.run', $config['run_manager']);
56
        }
57 10
        if (isset($config['job_timing_manager'])) {
58 1
            $container->setParameter('dtc_queue.manager.job_timing', $config['job_timing_manager']);
59
        }
60 10
        if (isset($config['document_manager'])) {
61 1
            $container->setParameter('dtc_queue.odm.document_manager', $config['document_manager']);
62
        }
63 10
        if (isset($config['entity_manager'])) {
64 1
            $container->setParameter('dtc_queue.orm.entity_manager', $config['entity_manager']);
65
        }
66 10
        $this->configClassDeprecated($config, $container);
67 10
        $this->configOtherDeprecated($config, $container);
68 10
    }
69
70 10
    protected function configClassDeprecated(array $config, ContainerBuilder $container)
71
    {
72 10
        if (isset($config['class_job'])) {
73 1
            $container->setParameter('dtc_queue.class.job', $config['class_job']);
74
        }
75 10
        if (isset($config['class_job_archive'])) {
76 1
            $container->setParameter('dtc_queue.class.job_archive', $config['class_job_archive']);
77
        }
78 10
        if (isset($config['class_run'])) {
79 1
            $container->setParameter('dtc_queue.class.run', $config['class_run']);
80
        }
81 10
        if (isset($config['class_run_archive'])) {
82 1
            $container->setParameter('dtc_queue.class.run_archive', $config['class_run_archive']);
83
        }
84 10
        if (isset($config['class_job_timing'])) {
85 1
            $container->setParameter('dtc_queue.class.job_timing', $config['class_job_timing']);
86
        }
87 10
    }
88
89 10
    protected function configOtherDeprecated(array $config, ContainerBuilder $container)
90
    {
91 10
        if (isset($config['record_timings'])) {
92 1
            $container->setParameter('dtc_queue.timings.record', $config['record_timings']);
93
        }
94 10
        if (isset($config['record_timings_timezone_offset'])) {
95 1
            $container->setParameter('dtc_queue.timings.timezone_offset', $config['record_timings_timezone_offset']);
96
        }
97 10
        if (isset($config['record_timings_timezone_offset'])) {
98 1
            $container->setParameter('dtc_queue.timings.timezone_offset', $config['record_timings_timezone_offset']);
99
        }
100 10
        if (isset($config['priority_max'])) {
101 1
            $container->setParameter('dtc_queue.priority.max', $config['priority_max']);
102
        }
103 10
        if (isset($config['priority_direction'])) {
104 1
            $container->setParameter('dtc_queue.priority.direction', $config['priority_direction']);
105
        }
106 10
    }
107
108 10
    protected function configRedis(array $config, ContainerBuilder $container)
109
    {
110 10
        $container->setParameter('dtc_queue.redis.prefix', $config['redis']['prefix']);
111 10
        if (isset($config['redis']['snc_redis']['type'])) {
112 1
            $container->setParameter('dtc_queue.redis.snc_redis.type', $config['redis']['snc_redis']['type']);
113 1
            $container->setParameter('dtc_queue.redis.snc_redis.alias', $config['redis']['snc_redis']['alias']);
114 9
        } elseif (isset($config['redis']['predis']['dsn'])) {
115 1
            $container->setParameter('dtc_queue.redis.predis.dsn', $config['redis']['predis']['dsn']);
116 9
        } elseif (isset($config['redis']['predis']['connection_parameters']['host'])) {
117 1
            $container->setParameter('dtc_queue.redis.predis.connection_parameters', $config['redis']['predis']['connection_parameters']);
118
        }
119 10
        $this->configPhpRedis($config, $container);
120 10
    }
121
122 10
    protected function configPhpRedis(array $config, ContainerBuilder $container)
123
    {
124 10
        $container->setParameter('dtc_queue.redis.phpredis.host', isset($config['redis']['phpredis']['host']) ? $config['redis']['phpredis']['host'] : null);
125 10
        $container->setParameter('dtc_queue.redis.phpredis.port', isset($config['redis']['phpredis']['port']) ? $config['redis']['phpredis']['port'] : null);
126 10
        $container->setParameter('dtc_queue.redis.phpredis.timeout', isset($config['redis']['phpredis']['timeout']) ? $config['redis']['phpredis']['timeout'] : null);
127 10
        $container->setParameter('dtc_queue.redis.phpredis.retry_interval', isset($config['redis']['phpredis']['retry_interval']) ? $config['redis']['phpredis']['retry_interval'] : null);
128 10
        $container->setParameter('dtc_queue.redis.phpredis.read_timeout', isset($config['redis']['phpredis']['read_timeout']) ? $config['redis']['phpredis']['read_timeout'] : null);
129 10
        if (isset($config['redis']['phpredis']['auth'])) {
130 1
            $container->setParameter('dtc_queue.redis.phpredis.auth', $config['redis']['phpredis']['auth']);
131
        }
132 10
    }
133
134 10
    protected function configAdmin(array $config, ContainerBuilder $container)
135
    {
136 10
        $container->setParameter('dtc_queue.admin.chartjs', $config['admin']['chartjs']);
137 10
    }
138
139 10
    protected function configClasses(array $config, ContainerBuilder $container)
140
    {
141 10
        $container->setParameter('dtc_queue.class.job', isset($config['class']['job']) ? $config['class']['job'] : null);
142 10
        $container->setParameter('dtc_queue.class.job_archive', isset($config['class']['job_archive']) ? $config['class']['job_archive'] : null);
143 10
        $container->setParameter('dtc_queue.class.run', isset($config['class']['run']) ? $config['class']['run'] : null);
144 10
        $container->setParameter('dtc_queue.class.run_archive', isset($config['class']['run_archive']) ? $config['class']['run_archive'] : null);
145 10
        $container->setParameter('dtc_queue.class.job_timing', isset($config['class']['job_timing']) ? $config['class']['job_timing'] : null);
146 10
    }
147
148 10
    protected function configRecordTimings(array $config, ContainerBuilder $container)
149
    {
150 10
        $container->setParameter('dtc_queue.timings.record', isset($config['timings']['record']) ? $config['timings']['record'] : false);
151 10
        $container->setParameter('dtc_queue.timings.timezone_offset', $config['timings']['timezone_offset']);
152 10
    }
153
154 10
    protected function configRabbitMQ(array $config, ContainerBuilder $container)
155
    {
156 10
        if (isset($config['rabbit_mq'])) {
157 1
            foreach (['host', 'port', 'user', 'password'] as $value) {
158 1
                if (!isset($config['rabbit_mq'][$value])) {
159 1
                    throw new InvalidConfigurationException('dtc_queue: rabbit_mq must have '.$value.' in config.yml');
160
                }
161
            }
162 1
            $config['rabbit_mq']['queue_args']['max_priority'] = $config['priority']['max'];
163 1
            $container->setParameter('dtc_queue.rabbit_mq', $config['rabbit_mq']);
164
        }
165 10
    }
166
167 10
    protected function configBeanstalkd(array $config, ContainerBuilder $container)
168
    {
169 10
        if (isset($config['beanstalkd'])) {
170 1
            if (!isset($config['beanstalkd']['host'])) {
171 1
                throw new InvalidConfigurationException('dtc_queue: beanstalkd requires host in config.yml');
172
            }
173
        }
174
175 10
        if (isset($config['beanstalkd']['host'])) {
176 1
            $container->setParameter('dtc_queue.beanstalkd.host', $config['beanstalkd']['host']);
177
        }
178 10
        if (isset($config['beanstalkd']['port'])) {
179 1
            $container->setParameter('dtc_queue.beanstalkd.port', $config['beanstalkd']['port']);
180
        }
181 10
        if (isset($config['beanstalkd']['tube'])) {
182 1
            $container->setParameter('dtc_queue.beanstalkd.tube', $config['beanstalkd']['tube']);
183
        }
184 10
    }
185
186 1
    public function getAlias(): string
187
    {
188 1
        return 'dtc_queue';
189
    }
190
}
191