pathauto-8.x-1.8/pathauto.module
pathauto.module
<?php
/**
* @file
* @defgroup pathauto Pathauto: Automatically generates aliases for content
*
* The Pathauto module automatically generates path aliases for various kinds of
* content (nodes, categories, users) without requiring the user to manually
* specify the path alias. This allows you to get aliases like
* /category/my-node-title.html instead of /node/123. The aliases are based upon
* a "pattern" system which the administrator can control.
*/
/**
* @file
* Main file for the Pathauto module, which automatically generates aliases for content.
*
* @ingroup pathauto
*/
use Drupal\Core\Hook\Attribute\LegacyHook;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\pathauto\Form\PatternEditForm;
use Drupal\pathauto\Hook\PathautoEntityHooks;
use Drupal\pathauto\Hook\PathautoHooks;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\pathauto\Hook\PathautoTokensHooks;
/**
* Implements hook_hook_info().
*/
function pathauto_hook_info() {
$hooks = [
'pathauto_pattern_alter',
'pathauto_alias_alter',
'pathauto_is_alias_reserved',
];
return array_fill_keys($hooks, ['group' => 'pathauto']);
}
/**
* Implements hook_help().
*/
#[LegacyHook]
function pathauto_help($route_name, RouteMatchInterface $route_match) {
return \Drupal::service(PathautoHooks::class)->help($route_name, $route_match);
}
/**
* Implements hook_entity_insert().
*/
#[LegacyHook]
function pathauto_entity_insert(EntityInterface $entity) {
\Drupal::service(PathautoEntityHooks::class)->entityInsert($entity);
}
/**
* Implements hook_entity_update().
*/
#[LegacyHook]
function pathauto_entity_update(EntityInterface $entity) {
\Drupal::service(PathautoEntityHooks::class)->entityUpdate($entity);
}
/**
* Implements hook_entity_delete().
*/
#[LegacyHook]
function pathauto_entity_delete(EntityInterface $entity) {
\Drupal::service(PathautoEntityHooks::class)->entityDelete($entity);
}
/**
* Implements hook_field_info_alter().
*/
#[LegacyHook]
function pathauto_field_info_alter(&$info) {
\Drupal::service(PathautoEntityHooks::class)->fieldInfoAlter($info);
}
/**
* Implements hook_field_widget_info_alter().
*/
#[LegacyHook]
function pathauto_field_widget_info_alter(&$widgets) {
\Drupal::service(PathautoEntityHooks::class)->fieldWidgetInfoAlter($widgets);
}
/**
* Implements hook_entity_base_field_info().
*/
#[LegacyHook]
function pathauto_entity_base_field_info(EntityTypeInterface $entity_type) {
return \Drupal::service(PathautoEntityHooks::class)->entityBaseFieldInfo($entity_type);
}
/**
* Validate the pattern field, to ensure it doesn't contain any characters that
* are invalid in URLs.
*
* @deprecated in pathauto:8.x-1.15 and is removed from pathauto:2.0.0. Use
* \Drupal\pathauto\Form\PatternEditForm::validatePattern() instead.
*
* @see https://www.drupal.org/node/3550710
*/
function pathauto_pattern_validate($element, FormStateInterface $form_state) {
@trigger_error(__FUNCTION__ . '() is deprecated in pathauto:8.x-1.15 and is removed from pathauto:2.0.0. Use \Drupal\pathauto\Form\PatternEditForm::validatePattern() instead. See https://www.drupal.org/node/3550710', E_USER_DEPRECATED);
return PatternEditForm::validatePattern($element, $form_state);
}
/**
* Implements hook_token_info().
*/
#[LegacyHook]
function pathauto_token_info() {
return \Drupal::service(PathautoTokensHooks::class)->tokenInfo();
}
/**
* Implements hook_tokens().
*/
#[LegacyHook]
function pathauto_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
return \Drupal::service(PathautoTokensHooks::class)->tokens($type, $tokens, $data, $options, $bubbleable_metadata);
}
