You are here

function zoomapi_get_entity_field_location in Zoom API 7.2

Get file filed location for entity field.

1 call to zoomapi_get_entity_field_location()
zoomapi_download_meeting_recordings_to_entity in ./zoomapi.module
Download meeting recordings for entity.

File

./zoomapi.module, line 1162
Main file for the Zoom API module.

Code

function zoomapi_get_entity_field_location($entity, $entity_type, $field_name) {
  $field_info = field_info_field($field_name);
  $uri_scheme = $field_info['settings']['uri_scheme'];
  if (is_numeric($entity)) {
    $entity = entity_load_single($entity_type, $entity);
  }
  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
  $field_instance_info = field_info_instance($entity_type, $field_name, $bundle);
  $file_directory = $field_instance_info['settings']['file_directory'];
  if (module_exists('filefield_paths') && !empty($field_instance_info['settings']['filefield_paths'])) {
    $settings = $field_instance_info['settings']['filefield_paths'];
    $settings['file_path']['options']['context'] = 'file_path';
    $token_data = [
      $entity_type => $entity,
    ];
    $file_directory = filefield_paths_process_string($settings['file_path']['value'], $token_data, $settings['file_path']['options']);
  }
  $destination_directory = "{$uri_scheme}://{$file_directory}";
  return $destination_directory;
}