public function Content::getContent in GatherContent 8.3
Same name and namespace in other branches
- 8 src/DAO/Content.php \Drupal\gathercontent\DAO\Content::getContent()
Get single piece of content.
Parameters
int $content_id: ID of content, we want to fetch.
Return value
null|object Content received from GatherContent.
File
- src/
DAO/ Content.php, line 127
Class
- Content
- Class Account.
Namespace
Drupal\gathercontent\DAOCode
public function getContent($content_id) {
$content = NULL;
try {
$response = $this->client
->get('/items/' . $content_id);
if ($response
->getStatusCode() === 200) {
$data = json_decode($response
->getBody());
$content = $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 $content;
}