1 path.api.php hook_path_info()

Provide information about the way your module's aliases will be built.

The information provided here is used to build the form on admin/config/urls/path/patterns.

@since 1.26.2 the 'pattern label' key was added to the return array.

Return value

array: A 2-level array of automatic path settings. Each item should have a unique key (often the name of the providing module). Each sub-array should contain the following:

  • entity type: The type of entity on which patterns will be created. All entities of this type will have a "path" property added to their objects upon loading.
  • label: Translated label for the settings group.
  • pattern label: The translated label for the default URL alias pattern (e.g. t('Default path pattern for content)').
  • pattern description: The translated help text for the default URL alias pattern (e.g. t('Fallback pattern for all content types without a specific URL alias pattern below.)').
  • pattern default: Default URL alias pattern (e.g. 'content/[node:title]')
  • type delete callback: The name of the function that should be run for bulk deletion of entity bundle types. See node_path_type_delete_callback() for an example.
  • batch update callback: The name of function that should be ran for bulk update. See node_path_bulk_update_batch_process() for an example.
  • batch file: The name of the file with the bulk update function.
  • source prefix: The prefix for source URLs generated for this type of path (e.g nodes have a source prefix of "node/" and taxonomy terms have a prefix of "taxonomy/term/". This is used when bulk deleting paths.
  • pattern items: Optional. An array of descriptions keyed by bundles.

See also

path_get_info()

path_entity_load()

path_entity_insert()

path_entity_update()

path_entity_delete()

File

core/modules/path/path.api.php, line 140
Hooks provided by the Path module.

Code

function hook_path_info() {
  // Aliases on files are not normally supported, this would add support for
  // auto-aliasing files.
  $info['file'] = array(
    'entity type' => 'file',
    'label' => t('File paths'),
    'pattern label' => t('Default path pattern for files'),
    'pattern description' => t('Fallback pattern for all files without a specific URL alias pattern below.'),
    'pattern default' => 'files/[file:name]',
    'type delete callback' => 'node_path_type_delete_callback',
    'batch update callback' => 'file_entity_path_bulk_update_batch_process',
    'batch file' => 'file.path.inc',
  );

  foreach (file_type_get_enabled_types() as $file_type => $type) {
    $info['file']['pattern items'][$file_type] = t('Pattern for all @file_type paths.', array('@file_type' => $type->label));
  }
  return $info;
}