function PMPAPIDrupal::getDoc in Public Media Platform API Integration 7
Gets a doc from the PMP.
Parameters
string $path: PMP query path.
4 calls to PMPAPIDrupal::getDoc()
- PMPAPIDrupal::delete in classes/
PMPAPIDrupal.php - Deletes a doc from the PMP
- PMPAPIDrupal::guid in classes/
PMPAPIDrupal.php - Generates a GUID
- PMPAPIDrupal::pull in classes/
PMPAPIDrupal.php - Pulls from the PMP.
- PMPAPIDrupal::push in classes/
PMPAPIDrupal.php - Takes node, creates Hypermedia doc, sends it to PMP API.
File
- classes/
PMPAPIDrupal.php, line 169 - Defines a class for PMP creation/transmission and retreival/parsing
Class
- PMPAPIDrupal
- @file
Code
function getDoc($path = '') {
$this
->sdkInclude('CollectionDocJson');
$url = $this->base . '/' . $path;
$key = $this
->cacheKey($path);
$cache = $this
->cacheGet($key);
if ($cache) {
$this->from_cache = TRUE;
return $cache;
}
elseif (!$this->errors) {
try {
$doc = new \Pmp\Sdk\CollectionDocJson($url, $this->auth_client);
$this
->cacheSet($key, $doc);
return $doc;
} catch (Exception $e) {
$message = t('Error fetching a doc from the PMP. Message: @exception', array(
'@exception' => $e
->getMessage(),
));
drupal_set_message($message, 'warning');
}
}
else {
drupal_set_message('Errors already present in object before doc could be fetched.');
}
}