Skip to content

Commit

Permalink
Merge pull request #2 from qpautrat/delete_queue_cli
Browse files Browse the repository at this point in the history
Delete queue cli
  • Loading branch information
qpautrat authored Apr 18, 2017
2 parents fbe3576 + c37b1af commit c8db720
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public function getConfigTreeBuilder()
->fixXmlConfig('publisher')
->fixXmlConfig('worker')
->children()
->scalarNode('default_driver')->end()
->arrayNode('drivers')
->requiresAtLeastOneElement()
->useAttributeAsKey('name')
->prototype('array')
->children()
Expand Down
43 changes: 42 additions & 1 deletion src/DependencyInjection/EvaneosBurrowExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
use Symfony\Component\DependencyInjection\Definition;
use Evaneos\BurrowBundle\WorkerFactory;
use Evaneos\Daemon\CLI\DaemonWorkerCommand;
use Burrow\CLI\DeleteExchangeCommand;
use Burrow\CLI\DeclareExchangeCommand;
use Burrow\CLI\DeleteQueueCommand;
use Burrow\CLI\DeclareQueueCommand;
use Burrow\CLI\BindCommand;

/**
* This is the class that loads and manages your bundle configuration.
Expand All @@ -28,7 +33,12 @@ public function load(array $configs, ContainerBuilder $container)
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

// var_dump($config); die;
if (!isset($config['default_driver'])) {
$keys = array_keys($config['drivers']);
$config['default_driver'] = reset($keys);
}

$container->setAlias('evaneos_burrow.default_driver', sprintf('evaneos_burrow.driver.%s', $config['default_driver']));

foreach ($config['drivers'] as $name => $driver) {
$container
Expand Down Expand Up @@ -60,5 +70,36 @@ public function load(array $configs, ContainerBuilder $container)
->addArgument(sprintf('burrow:consume:%s', $name))
->addTag('console.command');
}

$this->loadBurrowCommands($container);
}

private function loadBurrowCommands(ContainerBuilder $container)
{
$container
->register('evaneos_burrow.command.declare_queue', DeclareQueueCommand::class)
->addArgument(new Reference('evaneos_burrow.default_driver'))
->addMethodCall('setName', ['burrow:command:declare_queue'])
->addTag('console.command');
$container
->register('evaneos_burrow.command.delete_queue', DeleteQueueCommand::class)
->addArgument(new Reference('evaneos_burrow.default_driver'))
->addMethodCall('setName', ['burrow:command:delete_queue'])
->addTag('console.command');
$container
->register('evaneos_burrow.command.declare_exchange', DeclareExchangeCommand::class)
->addArgument(new Reference('evaneos_burrow.default_driver'))
->addMethodCall('setName', ['burrow:command:declare_exchange'])
->addTag('console.command');
$container
->register('evaneos_burrow.command.delete_exchange', DeleteExchangeCommand::class)
->addArgument(new Reference('evaneos_burrow.default_driver'))
->addMethodCall('setName', ['burrow:command:delete_exchange'])
->addTag('console.command');
$container
->register('evaneos_burrow.command.bind', BindCommand::class)
->addArgument(new Reference('evaneos_burrow.default_driver'))
->addMethodCall('setName', ['burrow:command:bind'])
->addTag('console.command');
}
}
8 changes: 4 additions & 4 deletions tests/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ framework:
evaneos_burrow:
drivers:
default:
host: rabbitmq_host
port: rabbitmq_port
user: rabbitmq_user
pwd: rabbitmq_pwd
host: localhost
port: 5672
user: guest
pwd: guest
publishers:
default:
driver: default
Expand Down

0 comments on commit c8db720

Please sign in to comment.