@@ -33,13 +33,16 @@ protected function configure()
33
33
$ this
34
34
->setName ('cache:clear ' )
35
35
->setDefinition (array (
36
- new InputOption ('no-warmup ' , '' , InputOption::VALUE_NONE , 'Do not warm up the cache ' )
36
+ new InputOption ('no-warmup ' , '' , InputOption::VALUE_NONE , 'Do not warm up the cache ' ),
37
+ new InputOption ('without-debug ' , '' , InputOption::VALUE_NONE , 'If the cache is warmed up, whether to disable debugging or not ' ),
37
38
))
38
39
->setDescription ('Clear the cache ' )
39
40
->setHelp (<<<EOF
40
- The <info>cache:clear</info> command clears the application cache for the current environment:
41
+ The <info>cache:clear</info> command clears the application cache for a given environment
42
+ and debug mode:
41
43
42
- <info>./app/console cache:clear</info>
44
+ <info>./app/console cache:clear dev</info>
45
+ <info>./app/console cache:clear prod --without-debug</info>
43
46
EOF
44
47
)
45
48
;
@@ -54,15 +57,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
54
57
$ oldCacheDir = $ realCacheDir .'_old ' ;
55
58
56
59
if (!is_writable ($ realCacheDir )) {
57
- throw new \RuntimeException (sprintf ('Unable to write in "%s" directory ' , $ this ->realCacheDir ));
60
+ throw new \RuntimeException (sprintf ('Unable to write in the "%s" directory ' , $ this ->realCacheDir ));
58
61
}
59
62
60
63
if ($ input ->getOption ('no-warmup ' )) {
61
64
rename ($ realCacheDir , $ oldCacheDir );
62
65
} else {
63
66
$ warmupDir = $ realCacheDir .'_new ' ;
64
67
65
- $ this ->warmup ($ warmupDir );
68
+ $ this ->warmup (! $ input -> getOption ( ' without-debug ' ), $ warmupDir );
66
69
67
70
rename ($ realCacheDir , $ oldCacheDir );
68
71
rename ($ warmupDir , $ realCacheDir );
@@ -71,18 +74,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
71
74
$ this ->container ->get ('filesystem ' )->remove ($ oldCacheDir );
72
75
}
73
76
74
- protected function warmup ($ warmupDir )
77
+ protected function warmup ($ debug , $ warmupDir )
75
78
{
76
79
$ this ->container ->get ('filesystem ' )->remove ($ warmupDir );
77
80
78
- $ kernel = $ this ->getTempKernel ($ this ->container ->get ('kernel ' ), $ warmupDir );
81
+ $ kernel = $ this ->getTempKernel ($ this ->container ->get ('kernel ' ), $ debug , $ warmupDir );
79
82
$ kernel ->boot ();
80
83
81
84
$ warmer = $ kernel ->getContainer ()->get ('cache_warmer ' );
82
85
$ warmer ->enableOptionalWarmers ();
83
86
$ warmer ->warmUp ($ warmupDir );
84
87
85
- // rename container files
88
+ // fix container files and classes
86
89
$ finder = new Finder ();
87
90
foreach ($ finder ->files ()->name (get_class ($ kernel ->getContainer ()).'* ' )->in ($ warmupDir ) as $ file ) {
88
91
$ content = file_get_contents ($ file );
@@ -92,7 +95,7 @@ protected function warmup($warmupDir)
92
95
}
93
96
}
94
97
95
- protected function getTempKernel (KernelInterface $ parent , $ warmupDir )
98
+ protected function getTempKernel (KernelInterface $ parent , $ debug , $ warmupDir )
96
99
{
97
100
$ parentClass = get_class ($ parent );
98
101
$ rand = uniqid ();
@@ -124,6 +127,6 @@ protected function getContainerClass()
124
127
require_once $ file ;
125
128
@unlink ($ file );
126
129
127
- return new $ class ($ parent ->getEnvironment (), $ parent -> isDebug () );
130
+ return new $ class ($ parent ->getEnvironment (), $ debug );
128
131
}
129
132
}
0 commit comments