Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
GatewayCommand Class Reference
Inheritance diagram for GatewayCommand:
CommandInterface

Public Member Functions

 __construct (BuilderInterface $requestBuilder, TransferFactoryInterface $transferFactory, ClientInterface $client, LoggerInterface $logger, HandlerInterface $handler=null, ValidatorInterface $validator=null, ErrorMessageMapperInterface $errorMessageMapper=null)
 
 execute (array $commandSubject)
 

Detailed Description

Class GatewayCommand @api @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Since
100.0.2

Definition at line 26 of file GatewayCommand.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( BuilderInterface  $requestBuilder,
TransferFactoryInterface  $transferFactory,
ClientInterface  $client,
LoggerInterface  $logger,
HandlerInterface  $handler = null,
ValidatorInterface  $validator = null,
ErrorMessageMapperInterface  $errorMessageMapper = null 
)
Parameters
BuilderInterface$requestBuilder
TransferFactoryInterface$transferFactory
ClientInterface$client
LoggerInterface$logger
HandlerInterface$handler
ValidatorInterface$validator
ErrorMessageMapperInterface | null$errorMessageMapper

Definition at line 72 of file GatewayCommand.php.

80  {
81  $this->requestBuilder = $requestBuilder;
82  $this->transferFactory = $transferFactory;
83  $this->client = $client;
84  $this->handler = $handler;
85  $this->validator = $validator;
86  $this->logger = $logger;
87  $this->errorMessageMapper = $errorMessageMapper;
88  }
$logger
catch(\Exception $e) $handler
Definition: index.php:30

Member Function Documentation

◆ execute()

execute ( array  $commandSubject)

Executes command basing on business object

Parameters
array$commandSubject
Returns
void
Exceptions
CommandException
ClientException
ConverterException

Implements CommandInterface.

Definition at line 99 of file GatewayCommand.php.

100  {
101  // @TODO implement exceptions catching
102  $transferO = $this->transferFactory->create(
103  $this->requestBuilder->build($commandSubject)
104  );
105 
106  $response = $this->client->placeRequest($transferO);
107  if ($this->validator !== null) {
108  $result = $this->validator->validate(
109  array_merge($commandSubject, ['response' => $response])
110  );
111  if (!$result->isValid()) {
112  $this->processErrors($result);
113  }
114  }
115 
116  if ($this->handler) {
117  $this->handler->handle(
118  $commandSubject,
119  $response
120  );
121  }
122  }
$response
Definition: 404.php:11

The documentation for this class was generated from the following file: