From 39b0e19c8b2e2fe38a4e34bd6485968de5f1008e Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 3 Dec 2015 09:47:28 -0600 Subject: [PATCH 1/3] Moves the RouteResultObserverInterface back to the Expressive namespace This patch moves the `RouteResultObserverInterface` into the `Zend\Expressive` namespace. Since it is triggered by `Application`, it is an application-level responsibility, not the router's. Since the class names do not conflict, this can lead to an immediate deprecation of the original interface in the zend-expressive-router package. However, zend-expressive-zendviewrenderer will need updates so that it fulfills the new interface via its `UrlHelper` instance. --- src/Application.php | 8 ++++---- src/RouteResultObserverInterface.php | 22 ++++++++++++++++++++++ test/RouteMiddlewareTest.php | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 src/RouteResultObserverInterface.php diff --git a/src/Application.php b/src/Application.php index cd29889a..ccaaca88 100644 --- a/src/Application.php +++ b/src/Application.php @@ -176,9 +176,9 @@ public function any($path, $middleware, $name = null) /** * Attach a route result observer. * - * @param Router\RouteResultObserverInterface $observer + * @param RouteResultObserverInterface $observer */ - public function attachRouteResultObserver(Router\RouteResultObserverInterface $observer) + public function attachRouteResultObserver(RouteResultObserverInterface $observer) { $this->routeResultObservers[] = $observer; } @@ -186,9 +186,9 @@ public function attachRouteResultObserver(Router\RouteResultObserverInterface $o /** * Detach a route result observer. * - * @param Router\RouteResultObserverInterface $observer + * @param RouteResultObserverInterface $observer */ - public function detachRouteResultObserver(Router\RouteResultObserverInterface $observer) + public function detachRouteResultObserver(RouteResultObserverInterface $observer) { if (false === ($index = array_search($observer, $this->routeResultObservers, true))) { return; diff --git a/src/RouteResultObserverInterface.php b/src/RouteResultObserverInterface.php new file mode 100644 index 00000000..ad4d72a0 --- /dev/null +++ b/src/RouteResultObserverInterface.php @@ -0,0 +1,22 @@ + Date: Thu, 3 Dec 2015 10:01:04 -0600 Subject: [PATCH 2/3] Updated CHANGELOG for #206 Also updates verbiage around #200, as the interface name has changed. --- CHANGELOG.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df9069f3..b7efdfa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,15 +17,16 @@ Third release candidate. array **must** be callables, service names resolving to callable middleware, or fully qualified class names that can be instantiated without arguments, and which result in invokable middleware. -- [#200](https://github.com/zendframework/zend-expressive/pull/200) adds a new - interface, `Zend\Expressive\Router\RouteResultObserverInterface` (since moved - to the zend-expressive-router package). `Zend\Expressive\Application` now - also defines two methods, `attachRouteResultObserver()` and - `detachRouteResultObserver()`, which accept instances of the interface. During - `routeMiddleware()`, all observers are updated immediately following the call - to `RouterInterface::match()` with the `RouteResult` instance. This feature - enables the ability to notify objects of the calculated `RouteResult` without - needing to inject middleware into the system. +- [#200](https://github.com/zendframework/zend-expressive/pull/200) and + [#206](https://github.com/zendframework/zend-expressive/pull/206) add a new + interface, `Zend\Expressive\RouteResultObserverInterface`. + `Zend\Expressive\Application` now also defines two methods, + `attachRouteResultObserver()` and `detachRouteResultObserver()`, which accept + instances of the interface. During `routeMiddleware()`, all observers are + updated immediately following the call to `RouterInterface::match()` with the + `RouteResult` instance. This feature enables the ability to notify objects of + the calculated `RouteResult` without needing to inject middleware into the + system. - [#81](https://github.com/zendframework/zend-expressive/pull/81) adds a cookbook entry for creating 404 handlers. From 394c87a0cc685d2c2dae13c3bdeb80c9dfed9e96 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 3 Dec 2015 10:15:13 -0600 Subject: [PATCH 3/3] Updated RouteResultObserverInterface documentation --- doc/book/router/result-observers.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/book/router/result-observers.md b/doc/book/router/result-observers.md index 174cc045..dbf80aae 100644 --- a/doc/book/router/result-observers.md +++ b/doc/book/router/result-observers.md @@ -21,7 +21,9 @@ you to notify such utilities of the results of matching. Route result observers must implement the `RouteResultObserverInterface`: ```php -namespace Zend\Expressive\Router; +namespace Zend\Expressive; + +use Zend\Expressive\Router\RouteResult; interface RouteResultObserverInterface { @@ -59,7 +61,7 @@ when invoked, generate a URI. ```php use Zend\Expressive\Router\RouterInterface; use Zend\Expressive\Router\RouteResult; -use Zend\Expressive\Router\RouteResultObserverInterface; +use Zend\Expressive\RouteResultObserverInterface; class UriGenerator implements RouteResultObserverInterface {