public function Project::getProjectObjects in GatherContent 8
Same name and namespace in other branches
- 8.3 src/DAO/Project.php \Drupal\gathercontent\DAO\Project::getProjectObjects()
Fetch projects from GatherContent.
Return value
array Associative array of projects.
File
- src/
DAO/ Project.php, line 104
Class
Namespace
Drupal\gathercontent\DAOCode
public function getProjectObjects() {
if (!$this->local) {
// @FIXME
$account = \Drupal::config('gathercontent.settings')
->get('gathercontent_account');
$account = unserialize($account);
$projects = array();
reset($account);
$account_id = key($account);
try {
$response = $this->client
->get('/projects?account_id=' . $account_id);
if ($response
->getStatusCode() === 200) {
$data = json_decode($response
->getBody());
foreach ($data->data as $project) {
if ($project->active) {
$projects[$project->id] = $project;
}
}
}
} catch (\Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
\Drupal::logger('gathercontent')
->error($e
->getMessage(), array());
}
return $projects;
}
else {
drupal_set_message(t('Error occured, please contact your system administrator'), 'error');
\Drupal::logger('gathercontent')
->alert('Object Project created as local, but trying to reach remote data.', []);
}
}