function rules_action_path_alias
Action implementation: Path alias.
Related topics
1 string reference to 'rules_action_path_alias'
- rules_path_action_info in modules/
path.rules.inc - Implements hook_rules_action_info() on behalf of the path module.
File
-
modules/
path.eval.inc, line 15
Code
function rules_action_path_alias($source, $alias, $langcode = LANGUAGE_NONE) {
if (!$alias) {
path_delete(array(
'source' => $source,
'language' => $langcode,
));
}
elseif (!$source) {
path_delete(array(
'alias' => $alias,
'language' => $langcode,
));
}
elseif (!path_load(array(
'alias' => $alias,
'language' => $langcode,
))) {
// Update the existing path or create a new one.
if ($path = path_load(array(
'source' => $source,
'language' => $langcode,
))) {
$path['alias'] = $alias;
}
else {
$path = array(
'source' => $source,
'alias' => $alias,
'language' => $langcode,
);
}
path_save($path);
}
else {
rules_log('The configured alias %alias already exists. Aborting.', array(
'%alias' => $alias,
));
}
}