Skip to content
Snippets Groups Projects
Commit 51e86bdf authored by Dave Reid's avatar Dave Reid
Browse files

Issue #1289550: The source and language contexts could not be altered from...

Issue #1289550: The source and language contexts could not be altered from hook_pathauto_alias_alter().
parent 2cb1cfe7
No related branches found
Tags 6.x-2.0
No related merge requests found
......@@ -14,7 +14,33 @@ function hook_path_alias_types() {
function hook_pathauto($op) {
}
function hook_pathauto_alias_alter(&$alias, $context) {
/**
* Alter Pathauto-generated aliases before saving.
*
* @param string $alias
* The automatic alias after token replacement and strings cleaned.
* @param array $context
* An associative array of additional options, with the following elements:
* - 'module': The module or type of object being aliased.
* - 'op': A string with the operation being performed on the object being
* aliased. Can be either 'insert', 'update', 'return', or 'bulkupdate'.
* - 'source': A string of the source path for the alias (e.g. 'node/1').
* This can be altered by reference.
* - 'data': An array of keyed objects to pass to token_replace(). Note this
* variable may not be consistent in older versions of Pathauto.
* - 'type': The sub-type or bundle of the object being aliased.
* - 'language': A string of the language code for the alias (e.g. 'en').
* This can be altered by reference.
* - 'pattern': A string of the pattern used for aliasing the object.
*
* @see pathauto_create_alias()
*/
function hook_pathauto_alias_alter(&$alias, &$context) {
// Add a suffix so that all aliases get saved as 'content/my-title.html'
$alias .= '.html';
// Force all aliases to be saved as language neutral.
$context['language'] = '';
}
/**
......
......@@ -398,7 +398,8 @@ function pathauto_clean_alias($alias) {
* is supported, otherwise you may pass the results from
* pathauto_get_placeholders() here.
* @param $entity_id
* The entity ID (node ID, user ID, etc.).
* (deprecated) The entity ID (node ID, user ID, etc.). This parameter is
* deprecated and is not actually used.
* @param $type
* For modules which provided pattern items in hook_pathauto(),
* the relevant identifier for the specific item to be aliased
......@@ -411,7 +412,7 @@ function pathauto_clean_alias($alias) {
* @see _pathauto_set_alias()
* @see pathauto_get_placeholders()
*/
function pathauto_create_alias($module, $op, $source, $data, $entity_id, $type = NULL, $language = '') {
function pathauto_create_alias($module, $op, $source, $data, $entity_id = NULL, $type = NULL, $language = '') {
// Retrieve and apply the pattern for this content type.
$pattern = pathauto_pattern_load_by_entity($module, $type, $language);
if (empty($pattern)) {
......@@ -461,10 +462,10 @@ function pathauto_create_alias($module, $op, $source, $data, $entity_id, $type =
$context = array(
'module' => $module,
'op' => $op,
'source' => $source,
'entity_id' => $entity_id,
'source' => &$source,
'data' => $data,
'type' => $type,
'language' => $language,
'language' => &$language,
'pattern' => $pattern,
);
drupal_alter('pathauto_alias', $alias, $context);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment