public function Content::getContents in GatherContent 8.3
Same name and namespace in other branches
- 8 src/DAO/Content.php \Drupal\gathercontent\DAO\Content::getContents()
Get list of content.
Parameters
int $project_id: ID of project we want items from.
Return value
array Array with content.
File
- src/
DAO/ Content.php, line 96
Class
- Content
- Class Account.
Namespace
Drupal\gathercontent\DAOCode
public function getContents($project_id) {
$accounts = [];
try {
$response = $this->client
->get('/items?project_id=' . $project_id);
if ($response
->getStatusCode() === 200) {
$data = json_decode($response
->getBody());
$accounts = $data->data;
}
else {
drupal_set_message(t("User with provided credentials wasn't found."), 'error');
}
} catch (\Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
\Drupal::logger('gathercontent')
->error($e
->getMessage(), []);
}
return $accounts;
}