This repository was archived by the owner on Jan 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace phpFastCache \Bundle \Command ;
3+
4+ use Symfony \Bundle \FrameworkBundle \Command \ContainerAwareCommand ;
5+ use Symfony \Component \Console \Input \InputArgument ;
6+ use Symfony \Component \Console \Input \InputInterface ;
7+ use Symfony \Component \Console \Output \OutputInterface ;
8+ use Symfony \Component \Console \Style \SymfonyStyle ;
9+
10+ class phpFastCacheCommand extends ContainerAwareCommand
11+ {
12+ protected function configure ()
13+ {
14+ $ this
15+ ->setName ('phpfastcache:clear ' )
16+ ->setDescription ('Clear phpfastcache cache ' )
17+ ->addArgument (
18+ 'driver ' ,
19+ InputArgument::OPTIONAL ,
20+ 'Cache name to clear '
21+ )
22+ ;
23+ }
24+ protected function execute (InputInterface $ input , OutputInterface $ output )
25+ {
26+ $ io = new SymfonyStyle ($ input , $ output );
27+
28+ $ phpFastCache = $ this ->getContainer ()->get ('phpfastcache ' );
29+ $ driver = $ input ->getArgument ('driver ' );
30+ if ($ driver ) {
31+ $ phpFastCache ->get ($ driver )->clear ();
32+ $ io ->success ("Cache {$ driver } cleared " );
33+ } else {
34+ $ caches = $ this ->getContainer ()->getParameter ('phpfastcache ' );
35+ foreach ($ caches ['drivers ' ] as $ name => $ parameters ) {
36+ if (OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
37+ $ output ->writeln ("Cache {$ name } cleared " );
38+ }
39+ $ phpFastCache ->get ($ name )->clear ();
40+ }
41+ $ io ->success ('All caches cleared ' );
42+ }
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments