Interface Yiisoft\Router\UrlGeneratorInterface
UrlGeneratorInterface allows generating URL given route name, arguments, and query parameters.
Psalm Types
| Name | Value |
|---|---|
| UrlArgumentsType | array<string, scalar|\Stringable|null> |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| generate() | Generates URL from named route, arguments, and query parameters. | Yiisoft\Router\UrlGeneratorInterface |
| generateAbsolute() | Generates absolute URL from named route, arguments, and query parameters. | Yiisoft\Router\UrlGeneratorInterface |
| generateFromCurrent() | Generate URL from the current route replacing some of its arguments with values specified. | Yiisoft\Router\UrlGeneratorInterface |
| getUriPrefix() | Yiisoft\Router\UrlGeneratorInterface | |
| setDefaultArgument() | Set default argument value. | Yiisoft\Router\UrlGeneratorInterface |
| setUriPrefix() | Yiisoft\Router\UrlGeneratorInterface |
Method Details
Generates URL from named route, arguments, and query parameters.
| public abstract string generate ( string $name, array $arguments = [], array $queryParameters = [], string|null $hash = null ) | ||
| $name | string |
Name of the route. |
| $arguments | array |
Argument-value set. Unused arguments will be moved to query parameters, if query parameter with such name doesn't exist. |
| $queryParameters | array |
Parameter-value set. |
| $hash | string|null |
Hash part (fragment identifier) of the URL. |
| return | string |
URL generated. |
|---|---|---|
| throws | Yiisoft\Router\RouteNotFoundException |
In case there is no route with the name specified. |
public function generate(
string $name,
array $arguments = [],
array $queryParameters = [],
?string $hash = null,
): string;
Generates absolute URL from named route, arguments, and query parameters.
| public abstract string generateAbsolute ( string $name, array $arguments = [], array $queryParameters = [], string|null $hash = null, string|null $scheme = null, string|null $host = null ) | ||
| $name | string |
Name of the route. |
| $arguments | array |
Argument-value set. Unused arguments will be moved to query parameters, if query parameter with such name doesn't exist. |
| $queryParameters | array |
Parameter-value set. |
| $hash | string|null |
Hash part (fragment identifier) of the URL. |
| $scheme | string|null |
Host scheme. |
| $host | string|null |
Host for manual setup. |
| return | string |
URL generated. |
|---|---|---|
| throws | Yiisoft\Router\RouteNotFoundException |
In case there is no route with the name specified. |
public function generateAbsolute(
string $name,
array $arguments = [],
array $queryParameters = [],
?string $hash = null,
?string $scheme = null,
?string $host = null
): string;
Generate URL from the current route replacing some of its arguments with values specified.
| public abstract string generateFromCurrent ( array $replacedArguments, array $queryParameters = [], string|null $hash = null, string|null $fallbackRouteName = null ) | ||
| $replacedArguments | array |
New argument values indexed by replaced argument names. Unused arguments will be moved to query parameters, if query parameter with such name doesn't exist. |
| $queryParameters | array |
Parameter-value set. |
| $hash | string|null |
Hash part (fragment identifier) of the URL. |
| $fallbackRouteName | string|null |
Name of a route that should be used if current route. can not be determined. |
public function generateFromCurrent(
array $replacedArguments,
array $queryParameters = [],
?string $hash = null,
?string $fallbackRouteName = null
): string;
Set default argument value.
| public abstract void setDefaultArgument ( string $name, boolean|float|integer|string|\Stringable|null $value ) | ||
| $name | string |
Name of argument to provide default value for. |
| $value | boolean|float|integer|string|\Stringable|null |
Default value. |
public function setDefaultArgument(string $name, bool|float|int|string|Stringable|null $value): void;
| public abstract void setUriPrefix ( string $name ) | ||
| $name | string | |
public function setUriPrefix(string $name): void;
Signup or Login in order to comment.