6
6
7
7
namespace Magento \Setup \Console \Command ;
8
8
9
+ use Magento \Framework \Filesystem ;
9
10
use Magento \Framework \App \Filesystem \DirectoryList ;
10
11
use Magento \Framework \ObjectManagerInterface ;
11
12
use Magento \Framework \App \DeploymentConfig ;
22
23
*/
23
24
class DiCompileCommand extends Command
24
25
{
25
- /**
26
- * @var DeploymentConfig
27
- */
26
+ /** @var DeploymentConfig */
28
27
private $ deploymentConfig ;
29
28
30
- /**
31
- * @var ObjectManagerInterface
32
- */
29
+ /** @var ObjectManagerInterface */
33
30
private $ objectManager ;
34
31
35
- /**
36
- * @var Manager
37
- */
32
+ /** @var Manager */
38
33
private $ taskManager ;
39
34
40
- /**
41
- * @var DirectoryList
42
- */
35
+ /** @var DirectoryList */
43
36
private $ directoryList ;
44
37
45
- /**
46
- * @var array
47
- */
48
- private $ excludedPathsList ;
38
+ /** @var Filesystem */
39
+ private $ filesystem ;
49
40
41
+ /** @var array */
42
+ private $ excludedPathsList ;
43
+
50
44
/**
51
45
* Constructor
52
46
*
53
47
* @param DeploymentConfig $deploymentConfig
54
48
* @param DirectoryList $directoryList
55
49
* @param Manager $taskManager
56
50
* @param ObjectManagerProvider $objectManagerProvider
51
+ * @param Filesystem $filesystem
57
52
*/
58
53
public function __construct (
59
54
DeploymentConfig $ deploymentConfig ,
60
55
DirectoryList $ directoryList ,
61
56
Manager $ taskManager ,
62
- ObjectManagerProvider $ objectManagerProvider
57
+ ObjectManagerProvider $ objectManagerProvider ,
58
+ Filesystem $ filesystem
63
59
) {
64
60
$ this ->deploymentConfig = $ deploymentConfig ;
65
- $ this ->directoryList = $ directoryList ;
66
- $ this ->objectManager = $ objectManagerProvider ->get ();
67
- $ this ->taskManager = $ taskManager ;
61
+ $ this ->directoryList = $ directoryList ;
62
+ $ this ->objectManager = $ objectManagerProvider ->get ();
63
+ $ this ->taskManager = $ taskManager ;
64
+ $ this ->filesystem = $ filesystem ;
68
65
parent ::__construct ();
69
66
}
70
67
@@ -92,6 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
92
89
$ output ->writeln ('You cannot run this command because the Magento application is not installed. ' );
93
90
return ;
94
91
}
92
+ $ this ->objectManager ->get ('Magento\Framework\App\Cache ' )->clean ();
95
93
$ compiledPathsList = [
96
94
'application ' => $ appCodePath ,
97
95
'library ' => $ libraryPath . '/Magento/Framework ' ,
@@ -141,6 +139,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
141
139
];
142
140
143
141
try {
142
+ $ this ->cleanupFilesystem (
143
+ [
144
+ DirectoryList::CACHE ,
145
+ DirectoryList::GENERATION ,
146
+ DirectoryList::DI ,
147
+ ]
148
+ );
144
149
foreach ($ operations as $ operationCode => $ arguments ) {
145
150
$ this ->taskManager ->addOperation (
146
151
$ operationCode ,
@@ -154,6 +159,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
154
159
}
155
160
}
156
161
162
+ /**
163
+ * Delete directories by their code from "var" directory
164
+ *
165
+ * @param array $directoryCodeList
166
+ * @return void
167
+ */
168
+ private function cleanupFilesystem ($ directoryCodeList )
169
+ {
170
+ foreach ($ directoryCodeList as $ code ) {
171
+ $ this ->filesystem ->getDirectoryWrite ($ code )->delete ();
172
+ }
173
+ }
174
+
157
175
/**
158
176
* Configure Object Manager
159
177
*
0 commit comments