function media_acquiadam_file_to_asset in Media: Acquia DAM 7
Given a file return the associated asset.
Parameters
object $file: A managed Drupal file.
Return value
AcquiaDAM_Assets_Asset|false An asset object or FALSE on failure.
4 calls to media_acquiadam_file_to_asset()
- media_acquiadam_browser_choose_asset_saved_landing_page in modules/
media_acquiadam_browser/ includes/ media_acquiadam_browser.pages.inc - Landing page for when someone selects assets with the browser form.
- media_acquiadam_dam_refresh_page in includes/
media_acquiadam.pages.inc - Refresh the Acquia DAM asset from the DAM source.
- media_acquiadam_dam_view_page in includes/
media_acquiadam.pages.inc - View the Acquia DAM asset on the DAM source.
- media_acquiadam_file_entity_access in ./
media_acquiadam.module - Implements hook_file_entity_access().
File
- includes/
media_acquiadam.helpers.inc, line 204 - Helper functions for working with Acquia DAM within Drupal.
Code
function media_acquiadam_file_to_asset($file) {
$asset_id = empty($file->acquiadam_id) ? NULL : $file->acquiadam_id;
if (empty($asset_id)) {
return FALSE;
}
try {
$asset = media_acquiadam_get_asset($asset_id);
} catch (Exception $x) {
watchdog_exception('media_acquiadam', $x);
}
return empty($asset) ? FALSE : $asset;
}