class AliasRepository implements AliasRepositoryInterface (View source)

Provides the default path alias lookup operations.

Properties

protected Connection $connection

The database connection.

Methods

__construct(Connection $connection)

Constructs an AliasRepository object.

string[]
preloadPathAlias(array $preloaded, string $langcode)

Pre-loads path alias information for a given list of system paths.

array|null
lookupBySystemPath(string $path, string $langcode)

Searches a path alias for a given Drupal system path.

array|null
lookupByAlias(string $alias, string $langcode)

Searches a path alias for a given alias.

bool
pathHasMatchingAlias(string $initial_substring)

Check if any alias exists starting with $initial_substring.

getBaseQuery()

Returns a SELECT query for the path_alias base table.

addLanguageFallback(SelectInterface $query, string $langcode)

Adds path alias language fallback conditions to a select query object.

Details

__construct(Connection $connection)

Constructs an AliasRepository object.

Parameters

Connection $connection

A database connection for reading and writing path aliases.

string[] preloadPathAlias(array $preloaded, string $langcode)

Pre-loads path alias information for a given list of system paths.

Parameters

array $preloaded

System paths that need preloading of aliases.

string $langcode

Language code to search the path with. If there's no path defined for that language it will search paths without language.

Return Value

string[]

System paths (keys) to alias (values) mapping.

array|null lookupBySystemPath(string $path, string $langcode)

Searches a path alias for a given Drupal system path.

The default implementation performs case-insensitive matching on the 'path' and 'alias' strings.

Parameters

string $path

The system path to investigate for corresponding path aliases.

string $langcode

Language code to search the path with. If there's no path defined for that language it will search paths without language.

Return Value

array|null

An array containing the 'id', 'path', 'alias' and 'langcode' properties of a path alias, or NULL if none was found.

array|null lookupByAlias(string $alias, string $langcode)

Searches a path alias for a given alias.

The default implementation performs case-insensitive matching on the 'path' and 'alias' strings.

Parameters

string $alias

The alias to investigate for corresponding system paths.

string $langcode

Language code to search the alias with. If there's no alias defined for that language it will search aliases without language.

Return Value

array|null

An array containing the 'id', 'path', 'alias' and 'langcode' properties of a path alias, or NULL if none was found.

bool pathHasMatchingAlias(string $initial_substring)

Check if any alias exists starting with $initial_substring.

Parameters

string $initial_substring

Initial system path substring to test against.

Return Value

bool

TRUE if any alias exists, FALSE otherwise.

protected SelectInterface getBaseQuery()

Returns a SELECT query for the path_alias base table.

Return Value

SelectInterface

A Select query object.

protected addLanguageFallback(SelectInterface $query, string $langcode)

Adds path alias language fallback conditions to a select query object.

Parameters

SelectInterface $query

A Select query object.

string $langcode

Language code to search the path with. If there's no path defined for that language it will search paths without language.