Skip to content

Commit a2daf81

Browse files
committed
MAGETWO-62400: Modules that use repositories in command line tools fail during setup:di:compile 2.1.x
- adding comments and setting class names by static accessor
1 parent c1cc006 commit a2daf81

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

app/code/Magento/Deploy/Console/CommandList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Magento\Framework\ObjectManagerInterface;
99

1010
/**
11-
* Class CommandList
11+
* This class groups and instantiates a list of deploy commands in order to be used separately before install
1212
*/
1313
class CommandList implements \Magento\Framework\Console\CommandListInterface
1414
{
@@ -35,7 +35,7 @@ public function __construct(ObjectManagerInterface $objectManager)
3535
protected function getCommandsClasses()
3636
{
3737
return [
38-
'Magento\Deploy\Console\Command\DeployStaticContentCommand'
38+
\Magento\Deploy\Console\Command\DeployStaticContentCommand::class
3939
];
4040
}
4141

app/code/Magento/Deploy/cli_commands.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
*/
66

77
if (PHP_SAPI == 'cli') {
8-
\Magento\Framework\Console\CommandLocator::register('Magento\Deploy\Console\CommandList');
8+
\Magento\Framework\Console\CommandLocator::register(Magento\Deploy\Console\CommandList::class);
99
}

lib/internal/Magento/Framework/Console/Cli.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,19 @@ protected function getApplicationCommands()
126126
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
127127
$bootstrap = Bootstrap::create(BP, $params);
128128
$objectManager = $bootstrap->getObjectManager();
129-
/** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */
130-
$omProvider = $this->serviceManager->get('Magento\Setup\Model\ObjectManagerProvider');
131-
$omProvider->setObjectManager($objectManager);
132129

133-
if (class_exists('Magento\Setup\Console\CommandList')) {
130+
// Specialized setup command list available before and after M2 install
131+
if (class_exists('Magento\Setup\Console\CommandList')
132+
&& class_exists('Magento\Setup\Model\ObjectManagerProvide')
133+
) {
134+
/** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */
135+
$omProvider = $this->serviceManager->get(\Magento\Setup\Model\ObjectManagerProvider::class);
136+
$omProvider->setObjectManager($objectManager);
134137
$setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager);
135138
$commands = array_merge($commands, $setupCommandList->getCommands());
136139
}
137140

141+
// Allowing instances of all modular commands only after M2 install
138142
if ($objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) {
139143
/** @var \Magento\Framework\Console\CommandListInterface $commandList */
140144
$commandList = $objectManager->create(\Magento\Framework\Console\CommandListInterface::class);

0 commit comments

Comments
 (0)