public function Acquiadam::getAsset in Media: Acquia DAM 8
File
- src/
Acquiadam.php, line 103
Class
- Acquiadam
- Class Acquiadam.
Namespace
Drupal\media_acquiadamCode
public function getAsset($assetId, $include_xmp = FALSE) {
$asset = $this
->staticAssetCache('get', $assetId);
// @BUG: XMP-less assets may bypass static caching.
// Technically if the asset doesn't have xmp_metadata (and always returns
// an empty value) this will bypass the cache version each call.
$needs_xmp_get = $include_xmp && empty($asset->xmp_metadata);
try {
if (is_null($asset) || $needs_xmp_get) {
$this
->staticAssetCache('set', $assetId, $this->acquiaDamClient
->getAsset($assetId, $include_xmp) ?? FALSE);
}
} catch (ClientException $x) {
// We want specific handling for 404 errors so we can provide a more
// relateable error message.
if (404 != $x
->getCode()) {
throw $x;
}
$this->loggerChannel
->warning('Received a missing asset response when trying to load asset @assetID. Was the asset deleted in Acquia DAM? DAM API client returned a @code exception code with the following message: %message', [
'@assetID' => $assetId,
'@code' => $x
->getCode(),
'@message' => $x
->getMessage(),
]);
} catch (\Exception $x) {
$this
->staticAssetCache('set', $assetId, FALSE);
$this->loggerChannel
->debug($x
->getMessage());
}
return $this
->staticAssetCache('get', $assetId);
}