Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RouteCollection.php

function RouteCollection::addAlias

Sets an alias for an existing route.

Parameters

string $name The alias to create:

string $alias The route to alias:

Throws

InvalidArgumentException if the alias is for itself

File

vendor/symfony/routing/RouteCollection.php, line 360

Class

RouteCollection
A RouteCollection represents a set of Route instances.

Namespace

Symfony\Component\Routing

Code

public function addAlias(string $name, string $alias) : Alias {
    if ($name === $alias) {
        throw new InvalidArgumentException(\sprintf('Route alias "%s" can not reference itself.', $name));
    }
    unset($this->routes[$name], $this->priorities[$name]);
    return $this->aliases[$name] = new Alias($alias);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal