Skip to content

PathautoHelper

Helpers for working with the Pathauto module.


  • Full name: \Drupal\helper\PathautoHelper

Properties

pathautoGenerator

protected \Drupal\pathauto\PathautoGeneratorInterface $pathautoGenerator

moduleHandler

protected \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler

tokenEntityMapper

protected \Drupal\token\TokenEntityMapperInterface $tokenEntityMapper

Methods

__construct

public __construct(\Drupal\pathauto\PathautoGeneratorInterface $pathautoGenerator, \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler, \Drupal\token\TokenEntityMapperInterface $tokenEntityMapper): mixed

Parameters:

Parameter Type Description
$pathautoGenerator \Drupal\pathauto\PathautoGeneratorInterface
$moduleHandler \Drupal\Core\Extension\ModuleHandlerInterface
$tokenEntityMapper \Drupal\token\TokenEntityMapperInterface

getAlteredPattern

Get the altered pathauto pattern.

public getAlteredPattern(\Drupal\Core\Entity\EntityInterface $entity): string|null

Parameters:

Parameter Type Description
$entity \Drupal\Core\Entity\EntityInterface
The entity.

Return Value:

The pattern prior to token replacement if available or NULL.


hasAutomaticAlias

Determine if an entity has a manual path alias.

public hasAutomaticAlias(\Drupal\Core\Entity\EntityInterface $entity, bool $checkGenerated = false): bool

Parameters:

Parameter Type Description
$entity \Drupal\Core\Entity\EntityInterface
The entity object.
$checkGenerated bool
(optional) Also check to make sure the current alias matches what
Pathauto would currently generate for the alias.

Return Value:

TRUE if the entity has an automatic alias, or FALSE otherwise.