33namespace ReputationVIP \Bundle \QueueClientBundle \Command ;
44
55use ReputationVIP \QueueClient \QueueClientInterface ;
6- use Symfony \Bundle \ FrameworkBundle \Command \ContainerAwareCommand ;
6+ use Symfony \Component \ Console \Command \Command ;
77use Symfony \Component \Console \Helper \Table ;
88use Symfony \Component \Console \Helper \TableCell ;
99use Symfony \Component \Console \Input \InputArgument ;
1010use Symfony \Component \Console \Input \InputInterface ;
1111use Symfony \Component \Console \Input \InputOption ;
1212use Symfony \Component \Console \Output \OutputInterface ;
13- use Symfony \Component \DependencyInjection \Exception \ServiceNotFoundException ;
1413
15- class QueuesInfoCommand extends ContainerAwareCommand
14+ class QueuesInfoCommand extends Command
1615{
16+ /** @var QueueClientInterface */
17+ private $ queueClient ;
18+
19+ public function __construct (QueueClientInterface $ queueClient )
20+ {
21+ parent ::__construct ();
22+
23+ $ this ->queueClient = $ queueClient ;
24+ }
25+
1726 protected function configure ()
1827 {
1928 $ this
@@ -30,20 +39,13 @@ protected function configure()
3039 /**
3140 * @param InputInterface $input
3241 * @param OutputInterface $output
42+ *
3343 * @return int
3444 */
3545 protected function execute (InputInterface $ input , OutputInterface $ output )
3646 {
37- try {
38- /** @var QueueClientInterface $queueClient */
39- $ queueClient = $ this ->getContainer ()->get ('queue_client ' );
40- } catch (ServiceNotFoundException $ e ) {
41- $ output ->writeln ('No queue client service found. ' );
42-
43- return 1 ;
44- }
4547 $ queues = $ input ->getArgument ('queues ' );
46- $ queuesList = $ queueClient ->listQueues ();
48+ $ queuesList = $ this -> queueClient ->listQueues ();
4749 if (0 === count ($ queues )) {
4850 try {
4951 $ queues = $ queuesList ;
@@ -60,11 +62,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
6062 $ priorities = [];
6163
6264 if ($ input ->getOption ('alias ' )) {
63- $ queuesAliases = $ queueClient ->getAliases ();
65+ $ queuesAliases = $ this -> queueClient ->getAliases ();
6466 }
6567
6668 if ($ input ->getOption ('priority ' )) {
67- $ priorities = $ queueClient ->getPriorityHandler ()->getAll ();
69+ $ priorities = $ this -> queueClient ->getPriorityHandler ()->getAll ();
6870 }
6971
7072 foreach ($ queues as $ queue ) {
@@ -73,11 +75,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
7375 if ($ input ->getOption ('count ' )) {
7476 if ($ input ->getOption ('priority ' )) {
7577 foreach ($ priorities as $ priority ) {
76- $ count = $ queueClient ->getNumberMessages ($ queue , $ priority );
78+ $ count = $ this -> queueClient ->getNumberMessages ($ queue , $ priority );
7779 $ row [] = $ count ;
7880 }
7981 } else {
80- $ count = $ queueClient ->getNumberMessages ($ queue );
82+ $ count = $ this -> queueClient ->getNumberMessages ($ queue );
8183 $ row [] = $ count ;
8284 }
8385 }
0 commit comments