File tree 3 files changed +76
-8
lines changed
app/code/Magento/CatalogStorefrontConfig
3 files changed +76
-8
lines changed Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 6
6
*/
7
7
8
8
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 ' ;
10
10
exit (1 );
11
11
}
12
12
17
17
exit (1 );
18
18
}
19
19
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 ' );
27
23
$ application ->run ();
28
24
} catch (\Exception $ e ) {
29
25
while ($ e ) {
You can’t perform that action at this time.
0 commit comments