function MockAliasManager::addAlias

Same name in other branches
  1. 9 core/modules/system/src/Tests/Routing/MockAliasManager.php \Drupal\system\Tests\Routing\MockAliasManager::addAlias()
  2. 10 core/modules/system/src/Tests/Routing/MockAliasManager.php \Drupal\system\Tests\Routing\MockAliasManager::addAlias()
  3. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.