16
16
17
17
namespace Phpfastcache \Bundle \Command ;
18
18
19
+ use Phpfastcache \Bundle \Service \Phpfastcache ;
19
20
use Phpfastcache \Core \Pool \ExtendedCacheItemPoolInterface ;
20
21
use Phpfastcache \Exceptions \PhpfastcacheDriverCheckException ;
21
- use Symfony \Bundle \FrameworkBundle \Command \ContainerAwareCommand ;
22
22
use Symfony \Component \Console \Input \InputArgument ;
23
23
use Symfony \Component \Console \Input \InputInterface ;
24
24
use Symfony \Component \Console \Output \OutputInterface ;
25
25
use Symfony \Component \Console \Style \SymfonyStyle ;
26
+ use Symfony \Component \Console \Command \Command ;
26
27
27
- class PhpfastcacheCommand extends ContainerAwareCommand
28
+ class PhpfastcacheCommand extends Command
28
29
{
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
+
29
53
protected function configure ()
30
54
{
31
55
$ this
@@ -38,23 +62,28 @@ protected function configure()
38
62
)
39
63
;
40
64
}
65
+
66
+ /**
67
+ * @param \Symfony\Component\Console\Input\InputInterface $input
68
+ * @param \Symfony\Component\Console\Output\OutputInterface $output
69
+ * @return int|null|void
70
+ */
41
71
protected function execute (InputInterface $ input , OutputInterface $ output )
42
72
{
43
73
$ failedInstances = [];
44
74
$ io = new SymfonyStyle ($ input , $ output );
45
75
46
- $ phpFastCache = $ this ->getContainer ()->get ('phpfastcache ' );
47
76
$ driver = $ input ->getArgument ('driver ' );
48
77
49
78
$ output ->writeln ("<bg=yellow;fg=red>Clearing cache operation can take a while, please be patient...</> " );
50
79
51
- $ callback = function ($ name ) use ($ phpFastCache , $ output , &$ failedInstances )
80
+ $ callback = function ($ name ) use ($ output , &$ failedInstances )
52
81
{
53
82
try {
54
83
if (OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
55
84
$ output ->writeln ("<fg=yellow>Clearing instance {$ name } cache...</> " );
56
85
}
57
- $ phpFastCache ->get ($ name )->clear ();
86
+ $ this -> phpfastcache ->get ($ name )->clear ();
58
87
if (OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
59
88
$ output ->writeln ("<fg=green>Cache instance {$ name } cleared</> " );
60
89
}
@@ -67,7 +96,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
67
96
}
68
97
}
69
98
};
70
- $ caches = $ this ->getContainer ()->getParameter ('phpfastcache ' );
99
+
100
+ $ caches = $ this ->parameters ;
71
101
72
102
if ($ driver ) {
73
103
if (\array_key_exists ($ driver , $ caches ['drivers ' ])){
0 commit comments