You are here

function media_acquiadam_browser_get_trail in Media: Acquia DAM 7

Gets the parent hierarchy of the given folder.

Parameters

int $folderId: The folder ID to start with.

Return value

array An array of folder IDs from parent to child that includes the original ID.

1 call to media_acquiadam_browser_get_trail()
media_acquiadam_browser_choose_asset_form_fill_assets in modules/media_acquiadam_browser/includes/media_acquiadam_browser.forms.inc
Helper function to adjust the asset chooser form values.

File

modules/media_acquiadam_browser/includes/media_acquiadam_browser.helpers.inc, line 17
Helper functions for the Acquia DAM browser.

Code

function media_acquiadam_browser_get_trail($folderId) {
  $trail = [];
  if (!empty($folderId) && AcquiaDAM_Assets_Folder::ROOT_FOLDER_ID != $folderId) {
    try {
      $folder = media_acquiadam_get_folder($folderId);
      $parents = $folder
        ->getParents();
      $parents[] = $folderId;
      $trail = $folder
        ->getMultiple($parents);
    } catch (Exception $x) {
      drupal_set_message($x
        ->getMessage(), 'error');
      watchdog_exception('media_acquiadam_browser', $x);
    }
  }
  return $trail;
}