Skip to content

Commit 7e4f65b

Browse files
author
Dale Sikkema
committed
Merge branch 'MAGETWO-37504-st-compiler' into develop
2 parents 0cb6ecf + 527f0d6 commit 7e4f65b

File tree

1 file changed

+38
-20
lines changed

1 file changed

+38
-20
lines changed

setup/src/Magento/Setup/Console/Command/DiCompileCommand.php

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Setup\Console\Command;
88

9+
use Magento\Framework\Filesystem;
910
use Magento\Framework\App\Filesystem\DirectoryList;
1011
use Magento\Framework\ObjectManagerInterface;
1112
use Magento\Framework\App\DeploymentConfig;
@@ -22,49 +23,45 @@
2223
*/
2324
class DiCompileCommand extends Command
2425
{
25-
/**
26-
* @var DeploymentConfig
27-
*/
26+
/** @var DeploymentConfig */
2827
private $deploymentConfig;
2928

30-
/**
31-
* @var ObjectManagerInterface
32-
*/
29+
/** @var ObjectManagerInterface */
3330
private $objectManager;
3431

35-
/**
36-
* @var Manager
37-
*/
32+
/** @var Manager */
3833
private $taskManager;
3934

40-
/**
41-
* @var DirectoryList
42-
*/
35+
/** @var DirectoryList */
4336
private $directoryList;
4437

45-
/**
46-
* @var array
47-
*/
48-
private $excludedPathsList;
38+
/** @var Filesystem */
39+
private $filesystem;
4940

41+
/** @var array */
42+
private $excludedPathsList;
43+
5044
/**
5145
* Constructor
5246
*
5347
* @param DeploymentConfig $deploymentConfig
5448
* @param DirectoryList $directoryList
5549
* @param Manager $taskManager
5650
* @param ObjectManagerProvider $objectManagerProvider
51+
* @param Filesystem $filesystem
5752
*/
5853
public function __construct(
5954
DeploymentConfig $deploymentConfig,
6055
DirectoryList $directoryList,
6156
Manager $taskManager,
62-
ObjectManagerProvider $objectManagerProvider
57+
ObjectManagerProvider $objectManagerProvider,
58+
Filesystem $filesystem
6359
) {
6460
$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;
6865
parent::__construct();
6966
}
7067

@@ -92,6 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9289
$output->writeln('You cannot run this command because the Magento application is not installed.');
9390
return;
9491
}
92+
$this->objectManager->get('Magento\Framework\App\Cache')->clean();
9593
$compiledPathsList = [
9694
'application' => $appCodePath,
9795
'library' => $libraryPath . '/Magento/Framework',
@@ -141,6 +139,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
141139
];
142140

143141
try {
142+
$this->cleanupFilesystem(
143+
[
144+
DirectoryList::CACHE,
145+
DirectoryList::GENERATION,
146+
DirectoryList::DI,
147+
]
148+
);
144149
foreach ($operations as $operationCode => $arguments) {
145150
$this->taskManager->addOperation(
146151
$operationCode,
@@ -154,6 +159,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
154159
}
155160
}
156161

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+
157175
/**
158176
* Configure Object Manager
159177
*

0 commit comments

Comments
 (0)