Skip to content

Commit

Permalink
Handle symfony >= 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas COUET committed Nov 9, 2017
1 parent 597b3ad commit 8078d31
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Queue Client Bundle Changelog

## v1.1.0

- Handle symfony >= 3.3

## v1.0.3

- Change from error to warning when try to add alias on unknown queue
Expand Down
3 changes: 3 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function getConfigTreeBuilder()
->scalarNode('queues_file')
->defaultValue(__DIR__.'/../Resources/config/queues.yml')
->end()
->scalarNode('queue_prefix')
->defaultValue('')
->end()
->scalarNode('priority_handler')
->defaultValue('ReputationVIP\QueueClient\PriorityHandler\StandardPriorityHandler')
->end()
Expand Down
16 changes: 4 additions & 12 deletions DependencyInjection/QueueClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,16 @@ class QueueClientExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$adapterChoice = array(
'sqs' => 'ReputationVIP\QueueClient\Adapter\SQSAdapter',
'file' => 'ReputationVIP\QueueClient\Adapter\FileAdapter',
'memory' => 'ReputationVIP\QueueClient\Adapter\MemoryAdapter',
'null' => 'ReputationVIP\QueueClient\Adapter\NullAdapter'
);

$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__.'/../Resources/config')
);
$loader->load('services.yml');

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

$container->setParameter(
'queue_client.adapter.priority_handler.class',
Expand All @@ -39,8 +31,8 @@ public function load(array $configs, ContainerBuilder $container)
$config['queues_file']
);
$container->setParameter(
'queue_client.adapter.class',
$adapterChoice[$config['adapter']['type']]
'queue_client.queue_prefix',
$config['queue_prefix']
);
$container->setParameter(
'queue_client.config',
Expand Down
3 changes: 3 additions & 0 deletions QueueClientAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class QueueClientAdapterFactory
public function get($config, $priorityHandler) {
$adapter = null;

var_dump($config['type']);
switch ($config['type']) {
case 'null':
$adapter = new NullAdapter();
Expand All @@ -40,6 +41,8 @@ public function get($config, $priorityHandler) {
case 'memory':
$adapter = new MemoryAdapter($priorityHandler);
break;
default:
throw new \InvalidArgumentException('Unknown handler type : ' . $config['type']);
}

return $adapter;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ queue_client:
### General configuration

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

### Available adapter types
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
class: ReputationVIP\Bundle\QueueClientBundle\QueueClientFactory

queue_client_adapter:
class: "%queue_client.adapter.class%"
class: ReputationVIP\QueueClient\Adapter\AbstractAdapter
factory: ["@queue_client_adapter_factory", get]
arguments:
- "%queue_client.config%"
Expand Down
4 changes: 2 additions & 2 deletions doc/queues-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It requires a main node `queues` with one sub node for each queue.

## Sample

```
```yaml
queue_client:
queues:
queue1:
Expand All @@ -16,7 +16,7 @@ queue_client:
- queue1-alias1
- queue1-alias2
queue2:
name: queue2
name: "%queue_client.queue_prefix%-queue2"
aliases:
- queue2-alias1
- queue2-alias2
Expand Down

0 comments on commit 8078d31

Please sign in to comment.