Skip to content

Commit c1cc006

Browse files
committed
MAGETWO-62400: Modules that use repositories in command line tools fail during setup:di:compile 2.1.x
- reverting accessible commands for all modules - publishing deploy command trough composer
1 parent 717ba2b commit c1cc006

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Deploy\Console;
7+
8+
use Magento\Framework\ObjectManagerInterface;
9+
10+
/**
11+
* Class CommandList
12+
*/
13+
class CommandList implements \Magento\Framework\Console\CommandListInterface
14+
{
15+
/**
16+
* Object Manager
17+
*
18+
* @var ObjectManagerInterface
19+
*/
20+
private $objectManager;
21+
22+
/**
23+
* @param ObjectManagerInterface $objectManager
24+
*/
25+
public function __construct(ObjectManagerInterface $objectManager)
26+
{
27+
$this->objectManager = $objectManager;
28+
}
29+
30+
/**
31+
* Gets list of command classes
32+
*
33+
* @return string[]
34+
*/
35+
protected function getCommandsClasses()
36+
{
37+
return [
38+
'Magento\Deploy\Console\Command\DeployStaticContentCommand'
39+
];
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
public function getCommands()
46+
{
47+
$commands = [];
48+
foreach ($this->getCommandsClasses() as $class) {
49+
if (class_exists($class)) {
50+
$commands[] = $this->objectManager->get($class);
51+
} else {
52+
throw new \Exception('Class ' . $class . ' does not exist');
53+
}
54+
}
55+
return $commands;
56+
}
57+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
if (PHP_SAPI == 'cli') {
8+
\Magento\Framework\Console\CommandLocator::register('Magento\Deploy\Console\CommandList');
9+
}

app/code/Magento/Deploy/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
],
1717
"autoload": {
1818
"files": [
19+
"cli_commands.php",
1920
"registration.php"
2021
],
2122
"psr-4": {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ protected function getApplicationCommands()
135135
$commands = array_merge($commands, $setupCommandList->getCommands());
136136
}
137137

138-
if (count($objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->get('modules'))) {
139-
/** @var \Magento\Framework\Console\CommandListInterface */
138+
if ($objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) {
139+
/** @var \Magento\Framework\Console\CommandListInterface $commandList */
140140
$commandList = $objectManager->create(\Magento\Framework\Console\CommandListInterface::class);
141141
$commands = array_merge($commands, $commandList->getCommands());
142142
}

0 commit comments

Comments
 (0)