Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommandList.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
20  private $objectManager;
21 
25  public function __construct(ObjectManagerInterface $objectManager)
26  {
27  $this->objectManager = $objectManager;
28  }
29 
35  protected function getCommandsClasses()
36  {
37  return [
38  \Magento\SampleData\Console\Command\SampleDataDeployCommand::class,
39  \Magento\SampleData\Console\Command\SampleDataRemoveCommand::class
40  ];
41  }
42 
46  public function getCommands()
47  {
48  $commands = [];
49  foreach ($this->getCommandsClasses() as $class) {
50  if (class_exists($class)) {
51  $commands[] = $this->objectManager->get($class);
52  } else {
53  throw new \Exception('Class ' . $class . ' does not exist');
54  }
55  }
56  return $commands;
57  }
58 }
$objectManager
Definition: bootstrap.php:17
$_option $_optionId $class
Definition: date.phtml:13
__construct(ObjectManagerInterface $objectManager)
Definition: CommandList.php:25