You are here

public function MockAliasManager::addAlias in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Routing/MockAliasManager.php \Drupal\system\Tests\Routing\MockAliasManager::addAlias()
  2. 9 core/modules/system/src/Tests/Routing/MockAliasManager.php \Drupal\system\Tests\Routing\MockAliasManager::addAlias()

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.

File

core/modules/system/src/Tests/Routing/MockAliasManager.php, line 50

Class

MockAliasManager
An easily configurable mock alias manager.

Namespace

Drupal\system\Tests\Routing

Code

public function addAlias($path, $alias, $path_language = NULL) {
  $language = $path_language ?: $this->defaultLanguage;
  if ($path[0] !== '/') {
    throw new \InvalidArgumentException('The path needs to start with a slash.');
  }
  if ($alias[0] !== '/') {
    throw new \InvalidArgumentException('The alias needs to start with a slash.');
  }
  $this->aliases[$path][$language] = $alias;
  $this->systemPaths[$alias][$language] = $path;
}