Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommandManager.php
Go to the documentation of this file.
1 <?php
7 
13 
21 {
25  private $commandPool;
26 
30  private $paymentDataObjectFactory;
31 
37  public function __construct(
38  CommandPoolInterface $commandPool,
39  PaymentDataObjectFactoryInterface $paymentDataObjectFactory
40  ) {
41  $this->commandPool = $commandPool;
42  $this->paymentDataObjectFactory = $paymentDataObjectFactory;
43  }
44 
56  public function executeByCode($commandCode, InfoInterface $payment = null, array $arguments = [])
57  {
58  $commandSubject = $arguments;
59  if ($payment !== null) {
60  $commandSubject['payment'] = $this->paymentDataObjectFactory->create($payment);
61  }
62 
63  return $this->commandPool
64  ->get($commandCode)
65  ->execute($commandSubject);
66  }
67 
78  public function execute(CommandInterface $command, InfoInterface $payment = null, array $arguments = [])
79  {
80  $commandSubject = $arguments;
81  if ($payment !== null) {
82  $commandSubject['payment'] = $this->paymentDataObjectFactory->create($payment);
83  }
84 
85  return $command->execute($commandSubject);
86  }
87 
96  public function get($commandCode)
97  {
98  return $this->commandPool->get($commandCode);
99  }
100 }
executeByCode($commandCode, InfoInterface $payment=null, array $arguments=[])
execute(CommandInterface $command, InfoInterface $payment=null, array $arguments=[])
$payment
Definition: order.php:17
$arguments
__construct(CommandPoolInterface $commandPool, PaymentDataObjectFactoryInterface $paymentDataObjectFactory)