You are here

public function MockAliasManager::addAlias in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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

type $path: The system path of the alias.

type $alias: The alias of the system path.

type $path_language: The language of this alias.

File

core/modules/system/src/Tests/Routing/MockAliasManager.php, line 55
Contains \Drupal\system\Tests\Routing\MockAliasManager.

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;
}