Skip to content

Commit 2cff537

Browse files
committed
SFAPP-310: setup:di:compile failures
1 parent 6b43344 commit 2cff537

File tree

3 files changed

+76
-8
lines changed

3 files changed

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

bin/command

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
if (PHP_SAPI !== 'cli') {
9-
echo 'bin/magento must be run as a CLI application';
9+
echo 'bin/command must be run as a CLI application';
1010
exit(1);
1111
}
1212

@@ -17,13 +17,9 @@ try {
1717
exit(1);
1818
}
1919
try {
20-
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
21-
$om = $bootstrap->getObjectManager();
22-
/** @var \Magento\Framework\Console\CommandListInterface $commandsList */
23-
$commandsList = $om->get(\Magento\Framework\Console\CommandListInterface::class);
24-
$commands = $commandsList->getCommands();
25-
$application = new \Symfony\Component\Console\Application('Magento CLI');
26-
$application->addCommands($commands);
20+
$handler = new \Magento\Framework\App\ErrorHandler();
21+
set_error_handler([$handler, 'handler']);
22+
$application = new \Magento\StorefrontFramework\Framework\Console\Cli('Magento CLI');
2723
$application->run();
2824
} catch (\Exception $e) {
2925
while ($e) {

0 commit comments

Comments
 (0)