Skip to content

Commit 8078d31

Browse files
author
Nicolas COUET
committed
Handle symfony >= 3.3
1 parent 597b3ad commit 8078d31

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Queue Client Bundle Changelog
22

3+
## v1.1.0
4+
5+
- Handle symfony >= 3.3
6+
37
## v1.0.3
48

59
- Change from error to warning when try to add alias on unknown queue

DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function getConfigTreeBuilder()
3838
->scalarNode('queues_file')
3939
->defaultValue(__DIR__.'/../Resources/config/queues.yml')
4040
->end()
41+
->scalarNode('queue_prefix')
42+
->defaultValue('')
43+
->end()
4144
->scalarNode('priority_handler')
4245
->defaultValue('ReputationVIP\QueueClient\PriorityHandler\StandardPriorityHandler')
4346
->end()

DependencyInjection/QueueClientExtension.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,16 @@ class QueueClientExtension extends Extension
1111
{
1212
public function load(array $configs, ContainerBuilder $container)
1313
{
14-
$adapterChoice = array(
15-
'sqs' => 'ReputationVIP\QueueClient\Adapter\SQSAdapter',
16-
'file' => 'ReputationVIP\QueueClient\Adapter\FileAdapter',
17-
'memory' => 'ReputationVIP\QueueClient\Adapter\MemoryAdapter',
18-
'null' => 'ReputationVIP\QueueClient\Adapter\NullAdapter'
19-
);
14+
2015
$configuration = new Configuration();
2116
$config = $this->processConfiguration($configuration, $configs);
2217

2318
$loader = new YamlFileLoader(
2419
$container,
2520
new FileLocator(__DIR__.'/../Resources/config')
2621
);
27-
$loader->load('services.yml');
2822

29-
if (!isset($adapterChoice[$config['adapter']['type']])) {
30-
throw new \InvalidArgumentException('Unknown handler type : ' . $config['adapter']['type']);
31-
}
23+
$loader->load('services.yml');
3224

3325
$container->setParameter(
3426
'queue_client.adapter.priority_handler.class',
@@ -39,8 +31,8 @@ public function load(array $configs, ContainerBuilder $container)
3931
$config['queues_file']
4032
);
4133
$container->setParameter(
42-
'queue_client.adapter.class',
43-
$adapterChoice[$config['adapter']['type']]
34+
'queue_client.queue_prefix',
35+
$config['queue_prefix']
4436
);
4537
$container->setParameter(
4638
'queue_client.config',

QueueClientAdapterFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class QueueClientAdapterFactory
2020
public function get($config, $priorityHandler) {
2121
$adapter = null;
2222

23+
var_dump($config['type']);
2324
switch ($config['type']) {
2425
case 'null':
2526
$adapter = new NullAdapter();
@@ -40,6 +41,8 @@ public function get($config, $priorityHandler) {
4041
case 'memory':
4142
$adapter = new MemoryAdapter($priorityHandler);
4243
break;
44+
default:
45+
throw new \InvalidArgumentException('Unknown handler type : ' . $config['type']);
4346
}
4447

4548
return $adapter;

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ queue_client:
4949
### General configuration
5050

5151
- ```queues_file``` specifies the default [queues configuration file](doc/queues-configuration-file.md).
52+
- ```queue_prefix``` specifies a queue prefix can use in [queues configuration file](doc/queues-configuration-file.md).
5253
- ```priority_handler``` specifies the priority handler. Default is the `ReputationVIP\QueueClient\PriorityHandler\StandardPriorityHandler`.
5354

5455
### Available adapter types

Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
class: ReputationVIP\Bundle\QueueClientBundle\QueueClientFactory
1010

1111
queue_client_adapter:
12-
class: "%queue_client.adapter.class%"
12+
class: ReputationVIP\QueueClient\Adapter\AbstractAdapter
1313
factory: ["@queue_client_adapter_factory", get]
1414
arguments:
1515
- "%queue_client.config%"

doc/queues-configuration-file.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ It requires a main node `queues` with one sub node for each queue.
77

88
## Sample
99

10-
```
10+
```yaml
1111
queue_client:
1212
queues:
1313
queue1:
@@ -16,7 +16,7 @@ queue_client:
1616
- queue1-alias1
1717
- queue1-alias2
1818
queue2:
19-
name: queue2
19+
name: "%queue_client.queue_prefix%-queue2"
2020
aliases:
2121
- queue2-alias1
2222
- queue2-alias2

0 commit comments

Comments
 (0)