Skip to content

Commit

Permalink
Reduced configureCommands complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
boekkooi committed Jun 10, 2015
1 parent cc73aeb commit f6db3d3
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/DependencyInjection/BoekkooiAMQPExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,7 @@ private function configureCommands(ContainerBuilder $container, array $config)
}

$class = ltrim($class, '\\');
$commands[$class] = [
'vhost' => $info['vhost'],
'exchange' => $info['exchange'],
'routing_key' => (isset($info['routing_key']) ? $info['routing_key'] : null),
'flags' => (
(isset($info['mandatory']) && $info['mandatory'] ? AMQP_MANDATORY : AMQP_NOPARAM) |
(isset($info['immediate']) && $info['immediate'] ? AMQP_IMMEDIATE : AMQP_NOPARAM)
),
'attributes' => (isset($info['attributes']) ? $info['attributes'] : [])
];
$commands[$class] = $this->retrieveCommandInformation($info);
}

$def = $container->getDefinition('boekkooi.amqp.tactician.transformer');
Expand All @@ -208,6 +199,20 @@ private function configureCommands(ContainerBuilder $container, array $config)
$def->addMethodCall('addSupportedCommands', [array_keys($commands)]);
}

private function retrieveCommandInformation(array $info)
{
return [
'vhost' => $info['vhost'],
'exchange' => $info['exchange'],
'routing_key' => (isset($info['routing_key']) ? $info['routing_key'] : null),
'flags' => (
(isset($info['mandatory']) && $info['mandatory'] ? AMQP_MANDATORY : AMQP_NOPARAM) |
(isset($info['immediate']) && $info['immediate'] ? AMQP_IMMEDIATE : AMQP_NOPARAM)
),
'attributes' => (isset($info['attributes']) ? $info['attributes'] : [])
];
}

private function configureMiddleware(ContainerBuilder $container, array $config)
{
$commandTransformer = new Reference($config['envelope_transformer']);
Expand Down

0 comments on commit f6db3d3

Please sign in to comment.