class TestRequestService in Entity Share 8.2
Class TestRequestService.
@package Drupal\entity_share_client_request_test\Service
Hierarchy
- class \Drupal\entity_share_client\Service\RequestService implements RequestServiceInterface
- class \Drupal\entity_share_client_request_test\Service\TestRequestService
Expanded class hierarchy of TestRequestService
1 string reference to 'TestRequestService'
- entity_share_client_request_test.services.yml in modules/
entity_share_client/ tests/ modules/ entity_share_client_request_test/ entity_share_client_request_test.services.yml - modules/entity_share_client/tests/modules/entity_share_client_request_test/entity_share_client_request_test.services.yml
1 service uses TestRequestService
- entity_share_client_request_test.request in modules/
entity_share_client/ tests/ modules/ entity_share_client_request_test/ entity_share_client_request_test.services.yml - Drupal\entity_share_client_request_test\Service\TestRequestService
File
- modules/
entity_share_client/ tests/ modules/ entity_share_client_request_test/ src/ Service/ TestRequestService.php, line 15
Namespace
Drupal\entity_share_client_request_test\ServiceView source
class TestRequestService extends RequestService {
/**
* A mapping, URL => response, from the GET requests made.
*
* @var \Psr\Http\Message\ResponseInterface[]
*/
protected $responseMapping = [];
/**
* {@inheritdoc}
*/
public function request(Client $http_client, $method, $url) {
// It it is a GET request store the result to be able to re-obtain the
// result to simulate another website.
if ($method == 'GET') {
if (!isset($this->responseMapping[$url])) {
$this->responseMapping[$url] = parent::request($http_client, $method, $url);
}
return $this->responseMapping[$url];
}
return parent::request($http_client, $method, $url);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TestRequestService:: |
protected | property | A mapping, URL => response, from the GET requests made. | |
TestRequestService:: |
public | function |
Performs a HTTP request. Wraps the Guzzle HTTP client. Overrides RequestService:: |