You are here

public function LingotekApi::getProject in Lingotek Translation 8

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

File

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

Class

LingotekApi

Namespace

Drupal\lingotek\Remote

Code

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