You are here

public function LingotekApi::getVaults in Lingotek Translation 8

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

Overrides LingotekApiInterface::getVaults

File

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

Class

LingotekApi

Namespace

Drupal\lingotek\Remote

Code

public function getVaults($community_id) {
  try {
    $this->logger
      ->debug('Lingotek::getVaults called with id ' . $community_id);

    // We ignore $community_id, as it is not needed for getting the TM vaults.
    $response = $this->lingotekClient
      ->get('/api/vault', array(
      'limit' => 100,
      'is_owned' => 'TRUE',
    ));
  } catch (\Exception $e) {
    $this->logger
      ->error('Error getting vaults for community %community: %message.', [
      '%community' => $community_id,
      '%message' => $e
        ->getMessage(),
    ]);
    throw new LingotekApiException('Failed to get vaults: ' . $e
      ->getMessage());
  }
  $this->logger
    ->debug('getVaults response received, code %code and body %body', [
    '%code' => $response
      ->getStatusCode(),
    '%body' => (string) $response
      ->getBody(TRUE),
  ]);
  return $this
    ->formatResponse($response);
}