diff --git a/CHANGELOG.md b/CHANGELOG.md index c7faa2be..0bedee0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ - Bug #257: Explicitly mark nullable parameters (@vjik) - Сhg #247: Change `UrlGeneratorInterface` contract: on URL generation all unused arguments must be moved to query parameters, if query parameter with such name doesn't exist (@vjik) +- New #262: Add `$hash` parameter to `UrlGeneratorInterface` methods: `generate()`, `generateAbsolute()` and + `generateFromCurrent()` (@vjik) ## 3.1.0 February 20, 2024 diff --git a/UPGRADE.md b/UPGRADE.md index f719f048..bc3c5f19 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -37,5 +37,10 @@ The following backward incompatible changes have been made. ### `UrlGeneratorInterface` changes -Contract is changed: on URL generation all unused arguments must be moved to query parameters, if query parameter with -such name doesn't exist. You should change your interface implementations accordingly. +Contract is changed: + +- on URL generation all unused arguments must be moved to query parameters, if query parameter with +such name doesn't exist; +- added `$hash` parameter to `generate()`, `generateAbsolute()` and `generateFromCurrent()` methods. + +You should change your interface implementations accordingly. diff --git a/src/UrlGeneratorInterface.php b/src/UrlGeneratorInterface.php index 6b657c61..27296402 100644 --- a/src/UrlGeneratorInterface.php +++ b/src/UrlGeneratorInterface.php @@ -20,6 +20,7 @@ interface UrlGeneratorInterface * @param array $arguments Argument-value set. Unused arguments will be moved to query parameters, if query * parameter with such name doesn't exist. * @param array $queryParameters Parameter-value set. + * @param string|null $hash Hash part (fragment identifier) of the URL. * * @throws RouteNotFoundException In case there is no route with the name specified. * @@ -27,7 +28,12 @@ interface UrlGeneratorInterface * * @psalm-param UrlArgumentsType $arguments */ - public function generate(string $name, array $arguments = [], array $queryParameters = []): string; + public function generate( + string $name, + array $arguments = [], + array $queryParameters = [], + ?string $hash = null, + ): string; /** * Generates absolute URL from named route, arguments, and query parameters. @@ -36,6 +42,7 @@ public function generate(string $name, array $arguments = [], array $queryParame * @param array $arguments Argument-value set. Unused arguments will be moved to query parameters, if query * parameter with such name doesn't exist. * @param array $queryParameters Parameter-value set. + * @param string|null $hash Hash part (fragment identifier) of the URL. * @param string|null $scheme Host scheme. * @param string|null $host Host for manual setup. * @@ -49,6 +56,7 @@ public function generateAbsolute( string $name, array $arguments = [], array $queryParameters = [], + ?string $hash = null, string $scheme = null, string $host = null ): string; @@ -59,6 +67,7 @@ public function generateAbsolute( * @param array $replacedArguments 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. * @param array $queryParameters Parameter-value set. + * @param string|null $hash Hash part (fragment identifier) of the URL. * @param string|null $fallbackRouteName Name of a route that should be used if current route. * can not be determined. * @@ -67,6 +76,7 @@ public function generateAbsolute( public function generateFromCurrent( array $replacedArguments, array $queryParameters = [], + ?string $hash = null, ?string $fallbackRouteName = null ): string;