You are here

protected function RemoteManager::doRequest in Entity Share 8.3

Performs a HTTP request.

Parameters

\GuzzleHttp\ClientInterface $client: The client which will do the request.

string $method: HTTP method.

string $url: URL to request.

Return value

\Psr\Http\Message\ResponseInterface||null The response or NULL if a problem occurred.

See also

\GuzzleHttp\ClientInterface::request()

3 calls to RemoteManager::doRequest()
RemoteManager::jsonApiRequest in modules/entity_share_client/src/Service/RemoteManager.php
Performs a HTTP request on a JSON:API endpoint. Wraps the HTTP client.
RemoteManager::request in modules/entity_share_client/src/Service/RemoteManager.php
Performs a HTTP request. Wraps the HTTP client.
TestRemoteManager::doRequest in modules/entity_share_client/tests/modules/entity_share_client_remote_manager_test/src/Service/TestRemoteManager.php
Performs a HTTP request.
1 method overrides RemoteManager::doRequest()
TestRemoteManager::doRequest in modules/entity_share_client/tests/modules/entity_share_client_remote_manager_test/src/Service/TestRemoteManager.php
Performs a HTTP request.

File

modules/entity_share_client/src/Service/RemoteManager.php, line 179

Class

RemoteManager
Service to wrap requests logic.

Namespace

Drupal\entity_share_client\Service

Code

protected function doRequest(ClientInterface $client, $method, $url) {
  $log_variables = [
    '@url' => $url,
    '@method' => $method,
  ];
  try {
    return $client
      ->request($method, $url);
  } catch (ClientException $exception) {
    $log_variables['@exception_message'] = $exception
      ->getMessage();
    $this->logger
      ->error('Client exception when requesting the URL: @url with method @method: @exception_message', $log_variables);
  } catch (ServerException $exception) {
    $log_variables['@exception_message'] = $exception
      ->getMessage();
    $this->logger
      ->error('Server exception when requesting the URL: @url with method @method: @exception_message', $log_variables);
  } catch (GuzzleException $exception) {
    $log_variables['@exception_message'] = $exception
      ->getMessage();
    $this->logger
      ->error('Guzzle exception when requesting the URL: @url with method @method: @exception_message', $log_variables);
  } catch (\Exception $exception) {
    $log_variables['@exception_message'] = $exception
      ->getMessage();
    $this->logger
      ->error('Error when requesting the URL: @url with method @method: @exception_message', $log_variables);
  }
  return NULL;
}