function pathauto_pattern_load_by_entity in Pathauto 7
Same name and namespace in other branches
- 6.2 pathauto.module \pathauto_pattern_load_by_entity()
Load an URL alias pattern by entity, bundle, and language.
Parameters
$entity: An entity (e.g. node, taxonomy, user, etc.)
$bundle: A bundle (e.g. content type, vocabulary ID, etc.)
$language: A language code, defaults to the LANGUAGE_NONE constant.
8 calls to pathauto_pattern_load_by_entity()
- PathautoTestHelper::assertEntityPattern in ./
pathauto.test - PathautoUnitTestCase::testPatternLoadByEntity in ./
pathauto.test - Test pathauto_pattern_load_by_entity().
- pathauto_blog_update_alias in ./
pathauto.module - Update the blog URL aliases for an individual user account.
- pathauto_create_alias in ./
pathauto.inc - Apply patterns to create an alias.
- pathauto_field_attach_form in ./
pathauto.module - Implements hook_field_attach_form().
1 string reference to 'pathauto_pattern_load_by_entity'
File
- ./
pathauto.module, line 130 - Main file for the Pathauto module, which automatically generates aliases for content.
Code
function pathauto_pattern_load_by_entity($entity, $bundle = '', $language = LANGUAGE_NONE) {
$patterns =& drupal_static(__FUNCTION__, array());
$pattern_id = "{$entity}:{$bundle}:{$language}";
if (!isset($patterns[$pattern_id])) {
$variables = array();
if ($language != LANGUAGE_NONE) {
$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];
}