Dynamic path aliases, pathauto patterns & automatic updating of aliases
- Create dynamic path aliases and pathauto patterns, for the cases where tokens are too limited
- Automatically update an entity alias when other entities that were used to build this alias are updated
This package requires PHP 7.1 and Drupal 8 or higher. It can be installed using Composer:
composer require wieni/wmpathauto
Sometimes when defining pathauto patterns, you'll notice the token
system is just too limited. This module supports building patterns and
aliases in code using plugins with annotations, respectively
@AliasBuilder
and @PatternBuilder
.
When updating an entity with a path alias, all entities, configs and other path aliases that were used to build that alias are stored in the database. In the future, when one of those path aliases, entities or configs are updated, the path alias that depends on them will be automatically regenerated.
There are multiple ways to define dependencies:
When your pathauto pattern uses supported tokens, dependencies will be
automatically added based on those tokens. For example, if your pattern
contains the [site:name]
token, the aliases using this pattern will be
regenerated when the site name is changed.
Support for more token types can be added by creating plugins with the
@PatternTokenDependencyProvider
annotation, defining the token type in the
type
parameter and implementing the
PatternTokenDependencyProviderInterface
interface.
Dependencies can also be added manually by creating plugins with the
@EntityAliasDependencyProvider
annotation, implementing the
EntityAliasDependencyProviderInterface
interface. Plugins with AliasBuilder
or
PatternBuilder
annotations implementing the same interface are also
considered.
All notable changes to this project will be documented in the CHANGELOG file.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Distributed under the MIT License. See the LICENSE file for more information.