Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Connector.php
Go to the documentation of this file.
1 <?php
7 
10 
16 class Connector
17 {
27  private $commands;
28 
32  private $objectManager;
33 
38  public function __construct(
39  array $commands,
40  ObjectManagerInterface $objectManager
41  ) {
42  $this->commands = $commands;
43  $this->objectManager = $objectManager;
44  }
45 
53  public function execute($commandName)
54  {
55  if (!array_key_exists($commandName, $this->commands)) {
56  throw new NotFoundException(__('Command was not found.'));
57  }
58 
60  $command = $this->objectManager->create($this->commands[$commandName]);
61 
62  return $command->execute();
63  }
64 }
$objectManager
Definition: bootstrap.php:17
__()
Definition: __.php:13
__construct(array $commands, ObjectManagerInterface $objectManager)
Definition: Connector.php:38