You are here

function hook_pathauto_alias_alter in Pathauto 8

Same name and namespace in other branches
  1. 6.2 pathauto.api.php \hook_pathauto_alias_alter()
  2. 6 pathauto.api.php \hook_pathauto_alias_alter()
  3. 7 pathauto.api.php \hook_pathauto_alias_alter()

Alter Pathauto-generated aliases before saving.

Parameters

string $alias: The automatic alias after token replacement and strings cleaned.

array $context: An associative array of additional options, with the following elements:

  • 'module': The module or entity type 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().
  • '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.
1 invocation of hook_pathauto_alias_alter()
PathautoGenerator::createEntityAlias in src/PathautoGenerator.php
Apply patterns to create an alias.

File

./pathauto.api.php, line 134
Documentation for pathauto API.

Code

function hook_pathauto_alias_alter(&$alias, array &$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'] = Language::LANGCODE_NOT_SPECIFIED;
}