interface AliasStorageInterface (View source)

deprecated \Drupal\Core\Path\AliasStorage is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the "path_alias.repository" service instead, or the entity storage handler for the "path_alias" entity type for CRUD methods.

Provides a class for CRUD operations on path aliases.

Methods

array|false
save(string $source, string $alias, string $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, int|null $pid = NULL)

Saves a path alias to the database.

array|false
load(array $conditions)

Fetches a specific URL alias from the database.

delete(array $conditions)

Deletes a URL alias.

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

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

string|false
lookupPathAlias(string $path, string $langcode)

Returns an alias of Drupal system URL.

string|false
lookupPathSource(string $path, string $langcode)

Returns Drupal system URL of an alias.

bool
aliasExists(string $alias, string $langcode, string|null $source = NULL)

Checks if alias already exists.

bool
languageAliasExists()

Checks if there are any aliases with language defined.

array
getAliasesForAdminListing(array $header, string|null $keys = NULL)

Loads aliases for admin listing.

bool
pathHasMatchingAlias(string $initial_substring)

Check if any alias exists starting with $initial_substring.

Details

array|false save(string $source, string $alias, string $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, int|null $pid = NULL)

Saves a path alias to the database.

Parameters

string $source

The internal system path.

string $alias

The URL alias.

string $langcode

(optional) The language code of the alias.

int|null $pid

(optional) Unique path alias identifier.

Return Value

array|false

FALSE if the path could not be saved or an associative array containing the following keys:

  • source (string): The internal system path with a starting slash.
  • alias (string): The URL alias with a starting slash.
  • pid (int): Unique path alias identifier.
  • langcode (string): The language code of the alias.
  • original: For updates, an array with source, alias and langcode with the previous values.

array|false load(array $conditions)

Fetches a specific URL alias from the database.

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

Parameters

array $conditions

An array of query conditions.

Return Value

array|false

FALSE if no alias was found or an associative array containing the following keys:

  • source (string): The internal system path with a starting slash.
  • alias (string): The URL alias with a starting slash.
  • pid (int): Unique path alias identifier.
  • langcode (string): The language code of the alias.

delete(array $conditions)

Deletes a URL alias.

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

Parameters

array $conditions

An array of criteria.

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

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

Parameters

array $preloaded

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[]

Source (keys) to alias (values) mapping.

string|false lookupPathAlias(string $path, string $langcode)

Returns an alias of Drupal system URL.

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

Parameters

string $path

The 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

string|false

A path alias, or FALSE if no path was found.

string|false lookupPathSource(string $path, string $langcode)

Returns Drupal system URL of an alias.

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

Parameters

string $path

The path to investigate for corresponding system URLs.

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|false

A Drupal system path, or FALSE if no path was found.

bool aliasExists(string $alias, string $langcode, string|null $source = NULL)

Checks if alias already exists.

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

Parameters

string $alias

Alias to check against.

string $langcode

Language of the alias.

string|null $source

(optional) Path that alias is to be assigned to.

Return Value

bool

TRUE if alias already exists and FALSE otherwise.

bool languageAliasExists()

Checks if there are any aliases with language defined.

Return Value

bool

TRUE if aliases with language exist.

array getAliasesForAdminListing(array $header, string|null $keys = NULL)

Loads aliases for admin listing.

Parameters

array $header

Table header.

string|null $keys

(optional) Search keyword that may include one or more '*' as wildcard values.

Return Value

array

Array of items to be displayed on the current page.

bool pathHasMatchingAlias(string $initial_substring)

Check if any alias exists starting with $initial_substring.

Parameters

string $initial_substring

Initial path substring to test against.

Return Value

bool

TRUE if any alias exists, FALSE otherwise.