@@ -29,59 +29,61 @@ protected function configure()
29
29
*/
30
30
protected function execute (InputInterface $ input , OutputInterface $ output )
31
31
{
32
- try {
33
- $ this ->comment ($ input , $ output , sprintf (
34
- 'Define rabbitmq <info>%s</info> vhost configuration ' ,
35
- $ this ->getVhost ($ input )
36
- ));
37
-
38
- $ vhostConfiguration = $ this ->getVhostConfiguration ($ input );
39
- $ vhostHandler = $ this ->getContainer ()->get ('ola_rabbit_mq_admin_toolkit.handler.vhost ' );
40
- $ creation = !$ vhostHandler ->exists ($ vhostConfiguration );
41
-
42
- $ vhostHandler ->define ($ vhostConfiguration );
43
-
44
- $ this ->success ($ input , $ output , sprintf (
45
- 'Rabbitmq "%s" vhost configuration successfully %s ! ' ,
46
- $ this ->getVhost ($ input ),
47
- $ creation ? 'created ' : 'updated '
48
- ));
49
- } catch (\Exception $ e ) {
50
- if (!$ this ->getContainer ()->getParameter ('ola_rabbit_mq_admin_toolkit.silent_failure ' )) {
51
- throw $ e ;
32
+ $ vhostList = $ this ->getVhostList ($ input );
33
+
34
+ foreach ($ vhostList as $ vhost ) {
35
+ try {
36
+ $ this ->comment ($ input , $ output , sprintf (
37
+ 'Define rabbitmq <info>%s</info> vhost configuration ' ,
38
+ $ vhost
39
+ ));
40
+
41
+ $ vhostConfiguration = $ this ->getVhostConfiguration ($ vhost );
42
+ $ vhostHandler = $ this ->getContainer ()->get ('ola_rabbit_mq_admin_toolkit.handler.vhost ' );
43
+ $ creation = !$ vhostHandler ->exists ($ vhostConfiguration );
44
+
45
+ $ vhostHandler ->define ($ vhostConfiguration );
46
+
47
+ $ this ->success ($ input , $ output , sprintf (
48
+ 'Rabbitmq "%s" vhost configuration successfully %s ! ' ,
49
+ $ vhost ,
50
+ $ creation ? 'created ' : 'updated '
51
+ ));
52
+ } catch (\Exception $ e ) {
53
+ if (!$ this ->getContainer ()->getParameter ('ola_rabbit_mq_admin_toolkit.silent_failure ' )) {
54
+ throw $ e ;
55
+ }
52
56
}
53
57
}
54
58
}
55
59
56
60
/**
57
- * Retrieve vhost's name to process
61
+ * Return Vhosts to process
58
62
*
59
63
* @param InputInterface $input
60
64
*
61
- * @return string
65
+ * @return array
62
66
*/
63
- private function getVhost (InputInterface $ input )
67
+ private function getVhostList (InputInterface $ input )
64
68
{
65
- $ vhost = $ input ->getArgument ('vhost ' );
66
- if (empty ($ vhost )) {
67
- $ vhost = $ this ->getContainer ()->getParameter ('ola_rabbit_mq_admin_toolkit.default_vhost ' );
69
+ $ inputVhost = $ input ->getArgument ('vhost ' );
70
+ $ vhostList = array ($ inputVhost );
71
+ if (empty ($ inputVhost )) {
72
+ $ vhostList = $ this ->getContainer ()->getParameter ('ola_rabbit_mq_admin_toolkit.vhost_list ' );
68
73
}
69
74
70
- return $ vhost ;
75
+ return $ vhostList ;
71
76
}
72
77
73
78
/**
74
- * @param InputInterface $input
75
- * @param OutputInterface $output
79
+ * @param string $vhost
76
80
*
77
81
* @return VhostConfiguration
78
82
*
79
83
* @throws \InvalidArgumentException
80
84
*/
81
- private function getVhostConfiguration (InputInterface $ input )
85
+ private function getVhostConfiguration ($ vhost )
82
86
{
83
- $ vhost = $ this ->getVhost ($ input );
84
-
85
87
$ serviceName = sprintf (
86
88
OlaRabbitMqAdminToolkitExtension::VHOST_MANAGER_SERVICE_TEMPLATE ,
87
89
$ vhost
0 commit comments