@@ -29,18 +29,20 @@ protected function execute(InputInterface $input, OutputInterface $output) : voi
2929 $ config = $ this ->container ->get ('config ' );
3030 $ viewCachePath = $ config ['view ' ][$ config ['view ' ]['type ' ]]['cache ' ];
3131 $ output ->writeln ('Files under ' .$ viewCachePath .' will be deleted. ' );
32- $ cachedViewFileFolders = glob ($ viewCachePath .'/* ' );
33- foreach ($ cachedViewFileFolders as $ folder ) {
34- $ files = glob ($ folder .'/* ' );
35- $ output ->writeln ('Files under ' .$ folder .' will be deleted. ' );
36- foreach ($ files as $ file ) {
37- $ unlinkResult = file_exists ($ file )
38- ? (unlink ($ file ) === true ) ? 'deleted. ' :'could \'t deleted '
39- :' file does not exist ' ;
40- $ output ->writeln ($ file . ' ' . $ unlinkResult );
32+ if ( (string ) $ viewCachePath !== '' ) {
33+ $ cachedViewFileFolders = glob ($ viewCachePath . '/* ' );
34+ foreach ($ cachedViewFileFolders as $ folder ) {
35+ $ files = glob ($ folder . '/* ' );
36+ $ output ->writeln ('Files under ' . $ folder . ' will be deleted. ' );
37+ foreach ($ files as $ file ) {
38+ $ unlinkResult = file_exists ($ file )
39+ ? (unlink ($ file ) === true ) ? 'deleted. ' : 'could \'t deleted '
40+ : ' file does not exist ' ;
41+ $ output ->writeln ($ file . ' ' . $ unlinkResult );
42+ }
43+ rmdir ($ folder );
44+ $ output ->writeln ($ folder . ' emptied. ' );
4145 }
42- rmdir ($ folder );
43- $ output ->writeln ($ folder .' emptied. ' );
4446 }
4547 $ output ->writeln ($ viewCachePath .' emptied. ' );
4648
0 commit comments