You are here

function cdn_basic_farfuture_get_identifier in CDN 7.2

Same name and namespace in other branches
  1. 6.2 cdn.basic.farfuture.inc \cdn_basic_farfuture_get_identifier()

Get the UFI (Unique File Identifier) for the file at a path.

Parameters

$path: The path to get a UFI for.

1 call to cdn_basic_farfuture_get_identifier()
cdn_file_url_alter in ./cdn.module
Implements hook_file_url_alter().

File

./cdn.basic.farfuture.inc, line 247
Far Future expiration setting for basic mode.

Code

function cdn_basic_farfuture_get_identifier($path) {
  static $ufi_info;
  static $mapping;

  // Gather all unique file identifier info.
  if (!isset($ufi_info)) {
    $ufi_info = module_invoke_all('cdn_unique_file_identifier_info');
  }

  // We only need to parse the textual CDN mapping once into a lookup table.
  if (!isset($mapping)) {
    $mapping = _cdn_basic_farfuture_parse_raw_mapping(variable_get(CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_MAPPING_VARIABLE, CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_MAPPING_DEFAULT));
  }
  $ufi_method = cdn_basic_farfuture_get_ufi_method($path, $mapping);
  $prefix = $ufi_info[$ufi_method]['prefix'];
  if (isset($ufi_info[$ufi_method]['value'])) {
    $value = $ufi_info[$ufi_method]['value'];
  }
  else {
    $callback = $ufi_info[$ufi_method]['callback'];
    $value = call_user_func_array($callback, array(
      $path,
    ));
  }
  return "{$prefix}:{$value}";
}