1616
1717namespace Phpfastcache \Bundle \Command ;
1818
19+ use Phpfastcache \Bundle \Service \Phpfastcache ;
1920use Phpfastcache \Core \Pool \ExtendedCacheItemPoolInterface ;
2021use Phpfastcache \Exceptions \PhpfastcacheDriverCheckException ;
21- use Symfony \Bundle \FrameworkBundle \Command \ContainerAwareCommand ;
2222use Symfony \Component \Console \Input \InputArgument ;
2323use Symfony \Component \Console \Input \InputInterface ;
2424use Symfony \Component \Console \Output \OutputInterface ;
2525use Symfony \Component \Console \Style \SymfonyStyle ;
26+ use Symfony \Component \Console \Command \Command ;
2627
27- class PhpfastcacheCommand extends ContainerAwareCommand
28+ class PhpfastcacheCommand extends Command
2829{
30+ /**
31+ * @var \Phpfastcache\Bundle\Service\Phpfastcache
32+ */
33+ protected $ phpfastcache ;
34+
35+ /**
36+ * @var
37+ */
38+ protected $ parameters ;
39+
40+ /**
41+ * PhpfastcacheCommand constructor.
42+ * @param \Phpfastcache\Bundle\Service\Phpfastcache $phpfastcache
43+ * @param $parameters
44+ */
45+ public function __construct (Phpfastcache $ phpfastcache , $ parameters )
46+ {
47+ $ this ->phpfastcache = $ phpfastcache ;
48+ $ this ->parameters = $ parameters ;
49+
50+ parent ::__construct ();
51+ }
52+
2953 protected function configure ()
3054 {
3155 $ this
@@ -38,23 +62,28 @@ protected function configure()
3862 )
3963 ;
4064 }
65+
66+ /**
67+ * @param \Symfony\Component\Console\Input\InputInterface $input
68+ * @param \Symfony\Component\Console\Output\OutputInterface $output
69+ * @return int|null|void
70+ */
4171 protected function execute (InputInterface $ input , OutputInterface $ output )
4272 {
4373 $ failedInstances = [];
4474 $ io = new SymfonyStyle ($ input , $ output );
4575
46- $ phpFastCache = $ this ->getContainer ()->get ('phpfastcache ' );
4776 $ driver = $ input ->getArgument ('driver ' );
4877
4978 $ output ->writeln ("<bg=yellow;fg=red>Clearing cache operation can take a while, please be patient...</> " );
5079
51- $ callback = function ($ name ) use ($ phpFastCache , $ output , &$ failedInstances )
80+ $ callback = function ($ name ) use ($ output , &$ failedInstances )
5281 {
5382 try {
5483 if (OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
5584 $ output ->writeln ("<fg=yellow>Clearing instance {$ name } cache...</> " );
5685 }
57- $ phpFastCache ->get ($ name )->clear ();
86+ $ this -> phpfastcache ->get ($ name )->clear ();
5887 if (OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
5988 $ output ->writeln ("<fg=green>Cache instance {$ name } cleared</> " );
6089 }
@@ -67,7 +96,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
6796 }
6897 }
6998 };
70- $ caches = $ this ->getContainer ()->getParameter ('phpfastcache ' );
99+
100+ $ caches = $ this ->parameters ;
71101
72102 if ($ driver ) {
73103 if (\array_key_exists ($ driver , $ caches ['drivers ' ])){
0 commit comments