You are here

public function LingotekApi::getProject in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 8 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getProject()
  2. 8.2 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()

Gets the project with the given ID.

Parameters

string $id: The project ID.

Return value

array|bool Array with project information.

Overrides LingotekApiInterface::getProject

File

src/Remote/LingotekApi.php, line 427

Class

LingotekApi
A simple connector to the Lingotek Translation API.

Namespace

Drupal\lingotek\Remote

Code

public function getProject($project_id) {
  try {
    $this->logger
      ->debug('Lingotek::getProject called with id %id', [
      '%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();
}