You are here

public function LingotekApi::getProjects in Lingotek Translation 8

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

Overrides LingotekApiInterface::getProjects

File

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

Class

LingotekApi

Namespace

Drupal\lingotek\Remote

Code

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