You are here

protected function LingotekApi::formatResponse in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  2. 8.2 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  3. 4.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  4. 3.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  5. 3.1.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  6. 3.2.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  7. 3.3.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  8. 3.5.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  9. 3.6.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  10. 3.7.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()
  11. 3.8.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::formatResponse()

Formats the response data as id => title based on the JSON returned properties.

Parameters

\Psr\Http\Message\ResponseInterface $response: A response.

Return value

array Array of titles keyed by id from the response entities.

5 calls to LingotekApi::formatResponse()
LingotekApi::getCommunities in src/Remote/LingotekApi.php
Gets the communities associated with the current account.
LingotekApi::getFilters in src/Remote/LingotekApi.php
Get the available filters on Lingotek.
LingotekApi::getProjects in src/Remote/LingotekApi.php
Gets the community related projects.
LingotekApi::getVaults in src/Remote/LingotekApi.php
Gets the community related vaults.
LingotekApi::getWorkflows in src/Remote/LingotekApi.php
Gets the community related workflows.

File

src/Remote/LingotekApi.php, line 448

Class

LingotekApi
A simple connector to the Lingotek Translation API.

Namespace

Drupal\lingotek\Remote

Code

protected function formatResponse($response) {
  $formatted_response = [];
  $json_response = json_decode($response
    ->getBody(), TRUE);
  if (!empty($json_response['entities'])) {
    foreach ($json_response['entities'] as $entity) {
      if (!empty($entity['properties']['id']) && !empty($entity['properties']['title'])) {
        $formatted_response[$entity['properties']['id']] = $entity['properties']['title'];
      }
    }
  }
  return $formatted_response;
}