You are here

public function LingotekApi::listProjects in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.2 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::listProjects()
  2. 7.3 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::listProjects()
  3. 7.4 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::listProjects()
  4. 7.5 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::listProjects()
  5. 7.6 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::listProjects()

Gets available Lingotek projects.

Parameters

$reset: A boolean value to determin whether we need to query the API

Return value

array An array of available projects with project IDs as keys, project labels as values.

File

lib/Drupal/lingotek/LingotekApi.php, line 861
Defines Drupal\lingotek\LingotekApi

Class

LingotekApi
@file Defines Drupal\lingotek\LingotekApi

Code

public function listProjects($reset = FALSE) {
  $projects = variable_get('lingotek_project_defaults', array());
  if (!empty($projects) && $reset == FALSE) {
    return $projects;
  }
  $response = $this
    ->request('listProjects');
  if (empty($response) || $response->results == 'fail') {
    return FALSE;
  }
  $projects = array();
  foreach ($response->projects as $project) {
    $projects[$project->id] = $project->name;
  }
  variable_set('lingotek_project_defaults', $projects);
  return $projects;
}