class MockAliasManager implements AliasManagerInterface (View source)

An easily configurable mock alias manager.

Properties

protected array $aliases

Array of mocked aliases. Keys are system paths, followed by language.

protected array $systemPaths

Array of mocked aliases. Keys are aliases, followed by language.

protected array $lookedUp

An index of aliases that have been requested.

string $defaultLanguage

The language to assume a path alias is for if not specified.

Methods

addAlias(string $path, string $alias, string $path_language = NULL)

Adds an alias to the in-memory alias table for this object.

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.

Details

addAlias(string $path, string $alias, string $path_language = NULL)

Adds an alias to the in-memory alias table for this object.

Parameters

string $path

The system path of the alias.

string $alias

The alias of the system path.

string $path_language

The language of this alias.

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.