33
44namespace Selami \Command \Cache ;
55
6- use Selami \ Console \Command as SelamiCommand ;
6+ use Symfony \ Component \ Console \Command \ Command ;
77use Symfony \Component \Console \Input \InputInterface ;
88use Symfony \Component \Console \Output \OutputInterface ;
99use Symfony \Component \Console \Exception \InvalidArgumentException ;
1010
11- class ClearViewData extends SelamiCommand
11+ class ClearViewData extends Command
1212{
13+ private $ config ;
14+
15+ public function __construct (array $ config , ?string $ name = null )
16+ {
17+ $ this ->config = $ config ;
18+ parent ::__construct ($ name );
19+ }
20+
1321 /**
1422 * @inheritdoc
1523 * @throws InvalidArgumentException
@@ -26,12 +34,10 @@ protected function configure() : void
2634 */
2735 protected function execute (InputInterface $ input , OutputInterface $ output ) : void
2836 {
29- $ config = $ this ->container ->get ('config ' );
30- $ viewCachePath = $ config ['view ' ][$ config ['view ' ]['type ' ]]['cache ' ];
37+ $ viewCachePath = $ this ->config [$ this ->config ['type ' ]]['cache ' ];
3138 $ output ->writeln ('Files under ' .$ viewCachePath .' will be deleted. ' );
32- if ( (string ) $ viewCachePath !== '' ) {
33- $ cachedViewFileFolders = glob ($ viewCachePath . '/* ' );
34- foreach ($ cachedViewFileFolders as $ folder ) {
39+ if ((string ) $ viewCachePath !== '' ) {
40+ foreach (glob ($ viewCachePath . '/* ' ) as $ folder ) {
3541 $ files = glob ($ folder . '/* ' );
3642 $ output ->writeln ('Files under ' . $ folder . ' will be deleted. ' );
3743 foreach ($ files as $ file ) {
@@ -45,6 +51,5 @@ protected function execute(InputInterface $input, OutputInterface $output) : voi
4551 }
4652 }
4753 $ output ->writeln ($ viewCachePath .' emptied. ' );
48-
4954 }
5055}
0 commit comments