Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ResponseResolver.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  private $converter;
17 
21  private $responseHandlers;
22 
27  public function __construct(ConverterInterface $converter, array $responseHandlers = [])
28  {
29  $this->converter = $converter;
30  $this->responseHandlers = $responseHandlers;
31  }
32 
39  {
40  $result = false;
41  $converterMediaType = $this->converter->getContentMediaType();
42 
44  if ($response->getBody() && is_int(strripos($response->getHeader('Content-Type'), $converterMediaType))) {
45  $responseBody = $this->converter->fromBody($response->getBody());
46  } else {
47  $responseBody = [];
48  }
49 
50  if (array_key_exists($response->getStatus(), $this->responseHandlers)) {
51  $result = $this->responseHandlers[$response->getStatus()]->handleResponse($responseBody);
52  }
53 
54  return $result;
55  }
56 }
$response
Definition: 404.php:11
__construct(ConverterInterface $converter, array $responseHandlers=[])