class AliasManager implements AliasManagerInterface, CacheDecoratorInterface (View source)

deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\path_alias\AliasManager instead.

The default alias manager implementation.

Traits

Provides a standard way to announce deprecated properties.

Properties

protected $deprecatedProperties {@inheritdoc}
protected AliasRepositoryInterface $pathAliasRepository

The path alias repository.

protected CacheBackendInterface $cache

Cache backend service.

protected string $cacheKey

The cache key to use when caching paths.

protected bool $cacheNeedsWriting

Whether the cache needs to be written.

protected LanguageManagerInterface $languageManager

Language manager for retrieving the default langcode when none is specified.

protected array $lookupMap

Holds the map of path lookups per language.

protected array $noPath

Holds an array of aliases for which no path was found.

protected AliasWhitelistInterface $whitelist

Holds the array of whitelisted path aliases.

protected array $noAlias

Holds an array of paths that have no alias.

protected array $langcodePreloaded

Whether preloaded path lookups has already been loaded.

protected array $preloadedPathLookups

Holds an array of previously looked up paths for the current request path.

Methods

__get($name)

Allows to access deprecated/removed properties.

__construct(AliasRepositoryInterface $alias_repository, AliasWhitelistInterface $whitelist, LanguageManagerInterface $language_manager, CacheBackendInterface $cache)

Constructs an AliasManager.

setCacheKey($key)

Specify the key to use when writing the cache.

writeCache()

Write the cache.

string
getPathByAlias(string $alias, string $langcode = NULL)

Given the alias, return the path it represents.

string
getAliasByPath(string $path, string $langcode = NULL)

Given a path, return the alias.

cacheClear($source = NULL)

Clear internal caches in alias manager.

An
pathAliasWhitelistRebuild(string $path = NULL)

Rebuild the path alias white list.

int
getRequestTime()

Wrapper method for REQUEST_TIME constant.

Details

__get($name)

Allows to access deprecated/removed properties.

This method must be public.

Parameters

$name

__construct(AliasRepositoryInterface $alias_repository, AliasWhitelistInterface $whitelist, LanguageManagerInterface $language_manager, CacheBackendInterface $cache)

Constructs an AliasManager.

Parameters

AliasRepositoryInterface $alias_repository

The path alias repository.

AliasWhitelistInterface $whitelist

The whitelist implementation to use.

LanguageManagerInterface $language_manager

The language manager.

CacheBackendInterface $cache

Cache backend.

setCacheKey($key)

Specify the key to use when writing the cache.

Parameters

$key

writeCache()

Write the cache.

string getPathByAlias(string $alias, string $langcode = NULL)

Given the alias, return the path it represents.

Parameters

string $alias

An alias.

string $langcode

An optional language code to look up the path in.

Return Value

string

The path represented by alias, or the alias if no path was found.

Exceptions

InvalidArgumentException

string getAliasByPath(string $path, string $langcode = NULL)

Given a path, return the alias.

Parameters

string $path

A path.

string $langcode

An optional language code to look up the path in.

Return Value

string

An alias that represents the path, or path if no alias was found.

Exceptions

InvalidArgumentException

cacheClear($source = NULL)

Clear internal caches in alias manager.

Parameters

$source

Source path of the alias that is being inserted/updated. Can be omitted if entire cache needs to be flushed.

protected An pathAliasWhitelistRebuild(string $path = NULL)

Rebuild the path alias white list.

Parameters

string $path

An optional path for which an alias is being inserted.

Return Value

An

array containing a white list of path aliases.

protected int getRequestTime()

Wrapper method for REQUEST_TIME constant.

Return Value

int