You are here

public function LingotekApi::getCommunities in Lingotek Translation 8

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

Overrides LingotekApiInterface::getCommunities

File

src/Remote/LingotekApi.php, line 280
Contains \Drupal\lingotek\Remote\LingotekApi.

Class

LingotekApi

Namespace

Drupal\lingotek\Remote

Code

public function getCommunities() {
  try {
    $this->logger
      ->debug('Lingotek::getCommunities called.');
    $response = $this->lingotekClient
      ->get('/api/community', [
      'limit' => 100,
    ]);
  } catch (\Exception $e) {
    $this->logger
      ->error('Error getting communities: %message.', [
      '%message' => $e
        ->getMessage(),
    ]);
    throw new LingotekApiException('Failed to get communities: ' . $e
      ->getMessage());
  }
  $this->logger
    ->debug('deleteTranslation response received, code %code and body %body', [
    '%code' => $response
      ->getStatusCode(),
    '%body' => (string) $response
      ->getBody(TRUE),
  ]);
  return $this
    ->formatResponse($response);
}