You are here

function _nodesymlinks_pathauto_pattern_load_by_entity in NodeSymlinks 6

Load an URL alias pattern by entity, bundle, and language.

Use this in Pathauto 1.x

Parameters

$entity: An entity (e.g. node, taxonomy, user, etc.)

$bundle: A bundle (e.g. node type, vocabulary ID, etc.)

$language: A language code, defaults to the language-neutral empty string.

$clear: An optional boolean to clear the function's internal cache if TRUE.

See also

pathauto_pattern_load_by_entity()

1 call to _nodesymlinks_pathauto_pattern_load_by_entity()
_nodesymlinks_form_field in ./nodesymlinks.inc
Helper function to generate custom nodesymlinks form item.

File

./nodesymlinks.pathauto.inc, line 140

Code

function _nodesymlinks_pathauto_pattern_load_by_entity($bundle = '', $language = '', $clear = FALSE) {
  static $patterns = array();
  $entity = 'nodesymlinks';
  if ($clear) {
    $patterns = array();
    return;
  }
  $pattern_id = "{$entity}:{$bundle}:{$language}";
  $pattern = '';
  if (!isset($patterns[$pattern_id])) {
    $variables = array();
    if ($language) {
      $variables[] = "pathauto_{$entity}_{$bundle}_{$language}_pattern";
    }
    if ($bundle) {
      $variables[] = "pathauto_{$entity}_{$bundle}_pattern";
    }
    $variables[] = "pathauto_{$entity}_pattern";
    foreach ($variables as $variable) {
      if ($pattern = trim(variable_get($variable, ''))) {
        break;
      }
    }
    $patterns[$pattern_id] = $pattern;
  }
  return $patterns[$pattern_id];
}