Skip to content

Commit 615965b

Browse files
Igor Melnikovvrann
authored andcommitted
MAGETWO-51592: Make single tenant compiler work when Magento not installed
1 parent 3cfdb8d commit 615965b

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

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

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Symfony\Component\Console\Output\OutputInterface;
1010
use Symfony\Component\Console\Input\InputOption;
1111
use Magento\Framework\App\DeploymentConfig;
12+
use Magento\Framework\Module\Status;
1213

1314
abstract class AbstractModuleManageCommand extends AbstractModuleCommand
1415
{
@@ -71,20 +72,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
7172
$output->writeln(implode(PHP_EOL, $messages));
7273
return;
7374
}
74-
/**
75-
* @var \Magento\Framework\Module\Status $status
76-
*/
77-
$status = $this->objectManager->get('Magento\Framework\Module\Status');
7875
try {
79-
$modulesToChange = $status->getModulesToChange($isEnable, $modules);
76+
$modulesToChange = $this->getStatus()->getModulesToChange($isEnable, $modules);
8077
} catch (\LogicException $e) {
8178
$output->writeln('<error>' . $e->getMessage() . '</error>');
8279
return;
8380
}
8481
if (!empty($modulesToChange)) {
8582
$force = $input->getOption(self::INPUT_KEY_FORCE);
8683
if (!$force) {
87-
$constraints = $status->checkConstraints($isEnable, $modulesToChange);
84+
$constraints = $this->getStatus()->checkConstraints($isEnable, $modulesToChange);
8885
if ($constraints) {
8986
$output->writeln(
9087
"<error>Unable to change status of modules because of the following constraints:</error>"
@@ -93,22 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9390
return;
9491
}
9592
}
96-
$status->setIsEnabled($isEnable, $modulesToChange);
97-
if ($isEnable) {
98-
$output->writeln('<info>The following modules have been enabled:</info>');
99-
$output->writeln('<info>- ' . implode("\n- ", $modulesToChange) . '</info>');
100-
$output->writeln('');
101-
if ($this->getDeploymentConfig()->isAvailable()) {
102-
$output->writeln(
103-
'<info>To make sure that the enabled modules are properly registered,'
104-
. " run 'setup:upgrade'.</info>"
105-
);
106-
}
107-
} else {
108-
$output->writeln('<info>The following modules have been disabled:</info>');
109-
$output->writeln('<info>- ' . implode("\n- ", $modulesToChange) . '</info>');
110-
$output->writeln('');
111-
}
93+
$this->setIsEnabled($isEnable, $modulesToChange, $output);
11294
$this->cleanup($input, $output);
11395
if ($force) {
11496
$output->writeln(
@@ -121,6 +103,43 @@ protected function execute(InputInterface $input, OutputInterface $output)
121103
}
122104
}
123105

106+
/**
107+
* Enable/disable modules
108+
*
109+
* @param bool $isEnable
110+
* @param string[] $modulesToChange
111+
* @param OutputInterface $output
112+
*/
113+
private function setIsEnabled($isEnable, $modulesToChange, $output)
114+
{
115+
$this->getStatus()->setIsEnabled($isEnable, $modulesToChange);
116+
if ($isEnable) {
117+
$output->writeln('<info>The following modules have been enabled:</info>');
118+
$output->writeln('<info>- ' . implode("\n- ", $modulesToChange) . '</info>');
119+
$output->writeln('');
120+
if ($this->getDeploymentConfig()->isAvailable()) {
121+
$output->writeln(
122+
'<info>To make sure that the enabled modules are properly registered,'
123+
. " run 'setup:upgrade'.</info>"
124+
);
125+
}
126+
} else {
127+
$output->writeln('<info>The following modules have been disabled:</info>');
128+
$output->writeln('<info>- ' . implode("\n- ", $modulesToChange) . '</info>');
129+
$output->writeln('');
130+
}
131+
}
132+
133+
/**
134+
* Get module status
135+
*
136+
* @return Status
137+
*/
138+
private function getStatus()
139+
{
140+
return $this->objectManager->get(Status::class);
141+
}
142+
124143
/**
125144
* Validate list of modules and return error messages
126145
*

setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public function testExecuteModulesNotEnabled()
103103
$tester = new CommandTester($this->command);
104104
$tester->execute([]);
105105
$this->assertEquals(
106-
'You cannot run this command because modules are not enabled. You can enable modules by running the \'module:'
107-
. 'enable --all\' command.' . PHP_EOL,
106+
'You cannot run this command because modules are not enabled. You can enable modules by running the '
107+
. "'module:enable --all' command." . PHP_EOL,
108108
$tester->getDisplay()
109109
);
110110
}

0 commit comments

Comments
 (0)