You are here

protected function ContributeManager::get in Contribute 8

Get data from remote server.

Parameters

string $uri: The remote URI.

Return value

mixed|null The returned data. Tequests to *.json files will be decoded.

7 calls to ContributeManager::get()
ContributeManager::getAccount in src/ContributeManager.php
Get account status.
ContributeManager::getOrganization in src/ContributeManager.php
An organization's information from Drupal.org.
ContributeManager::getOrganizationBadge in src/ContributeManager.php
Get an organization's membership badge from Drupal.org.
ContributeManager::getOrganizationLogo in src/ContributeManager.php
Get an organization's logo from Drupal.org.
ContributeManager::getUser in src/ContributeManager.php
Get the user account information from Drupal.org.

... See full list

File

src/ContributeManager.php, line 466

Class

ContributeManager
Class ContributeManager.

Namespace

Drupal\contribute

Code

protected function get($uri) {
  if (isset($this->cachedData[$uri])) {
    return $this->cachedData[$uri];
  }
  try {
    $response = $this->httpClient
      ->get($uri);
    $is_json = preg_match('/\\.json($|\\?)/', $uri) ? TRUE : FALSE;
    $data = $is_json ? Json::decode($response
      ->getBody()) : $response
      ->getBody();
  } catch (\Exception $exception) {
    $data = NULL;
  }
  $this->cachedData[$uri] = $data;
  return $data;
}