Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit d5f93ee

Browse files
committed
Documented UrlHelper and RouterInterface::generateUri changes
1 parent 6e98c9f commit d5f93ee

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

doc/book/features/helpers/url-helper.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ Each method will raise an exception if:
6464
represents a matching failure.
6565
- The given `$routeName` is not defined in the router.
6666

67+
> ### Signature changes
68+
>
69+
> The signature listed above is current as of version 3.0.0 of
70+
> zendframework/zend-expressive-helpers. Prior to that version, the helper only
71+
> accepted the route name and route parameters.
72+
6773
## Creating an instance
6874

6975
In order to use the helper, you will need to instantiate it with the current

doc/book/features/router/interface.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ Implementors should also read the following sections detailing the `Route` and
7676
`RouteResult` classes, to ensure that their implementations interoperate
7777
correctly.
7878

79+
> ### generateUri() signature change in 2.0
80+
>
81+
> Prior to zendframework/zend-expressive-router 2.0.0, the signature of
82+
> `generateUri()` was:
83+
>
84+
> ```php
85+
> public function generateUri(
86+
> string $name,
87+
> array $substitutions = []
88+
> ) : string
89+
> ```
90+
>
91+
> If you are targeting that version, you may still provide the `$options`
92+
> argument, but it will not be invoked.
93+
7994
## Routes
8095
8196
Routes are defined via `Zend\Expressive\Router\Route`, and aggregate the

doc/book/reference/migration/to-v2.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,3 +738,58 @@ entries for each will be injected into your generated pipeline.
738738

739739
Please see the [chapter on the implicit methods middleware](../../features/middleware/implicit-methods-middleware.md)
740740
for more information on each.
741+
742+
## Router interface changes
743+
744+
Expressive 2.0 uses zendframework/zend-expressive-router 2.1+. Version 2.0 of
745+
that package introduced a change to the `Zend\Expressive\Router\RouterInterface::generateUri()`
746+
method; it now accepts an additional, optional, third argument, `array $options = []`,
747+
which can be used to pass router-specific options when generating a URI. As an
748+
example, the implementation that uses zendframework/zend-router might use these
749+
options to pass a translator instance in order to translate a path segment to
750+
the currently selected locale.
751+
752+
For consumers, his represents no backwards-incompatible change; consumers may
753+
opt-in to the new argument at will. For those implementing the interface,
754+
upgrading will require updating your router implementation's signature to match
755+
the new interface:
756+
757+
```php
758+
public function generateUri(
759+
string $name,
760+
array $substitutions = [],
761+
array $options = []
762+
) : string
763+
```
764+
765+
## URL helper changes
766+
767+
Expressive 2.0 uses zendframework/zend-expressive-helpers version 3.0+. This new
768+
version updates the signature of the `Zend\Expressive\Helper\UrlHelper` from:
769+
770+
```php
771+
function (
772+
$routeName,
773+
array $routeParams = []
774+
) : string
775+
```
776+
777+
to:
778+
779+
```php
780+
function (
781+
$routeName,
782+
array $routeParams = [],
783+
$queryParams = [],
784+
$fragmentIdentifier = null,
785+
array $options = []
786+
) : string
787+
```
788+
789+
For consumers, this should represent a widening of features, and will not
790+
require any changes, unless you wish to opt-in to the new arguments. See the
791+
[UrlHelper documentation](../../features/helpers/url-helper.md) for information
792+
on each argument.
793+
794+
For any users who were _extending_ the class, you will need to update your
795+
extension accordingly.

0 commit comments

Comments
 (0)