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

Commit e161d2e

Browse files
committed
Merge branch 'hotfix/route-result-observer'
Close #206
2 parents 2ca2f21 + 394c87a commit e161d2e

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

CHANGELOG.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ Third release candidate.
1717
array **must** be callables, service names resolving to callable middleware,
1818
or fully qualified class names that can be instantiated without arguments, and
1919
which result in invokable middleware.
20-
- [#200](https://github.com/zendframework/zend-expressive/pull/200) adds a new
21-
interface, `Zend\Expressive\Router\RouteResultObserverInterface` (since moved
22-
to the zend-expressive-router package). `Zend\Expressive\Application` now
23-
also defines two methods, `attachRouteResultObserver()` and
24-
`detachRouteResultObserver()`, which accept instances of the interface. During
25-
`routeMiddleware()`, all observers are updated immediately following the call
26-
to `RouterInterface::match()` with the `RouteResult` instance. This feature
27-
enables the ability to notify objects of the calculated `RouteResult` without
28-
needing to inject middleware into the system.
20+
- [#200](https://github.com/zendframework/zend-expressive/pull/200) and
21+
[#206](https://github.com/zendframework/zend-expressive/pull/206) add a new
22+
interface, `Zend\Expressive\RouteResultObserverInterface`.
23+
`Zend\Expressive\Application` now also defines two methods,
24+
`attachRouteResultObserver()` and `detachRouteResultObserver()`, which accept
25+
instances of the interface. During `routeMiddleware()`, all observers are
26+
updated immediately following the call to `RouterInterface::match()` with the
27+
`RouteResult` instance. This feature enables the ability to notify objects of
28+
the calculated `RouteResult` without needing to inject middleware into the
29+
system.
2930
- [#81](https://github.com/zendframework/zend-expressive/pull/81) adds a
3031
cookbook entry for creating 404 handlers.
3132

doc/book/router/result-observers.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ you to notify such utilities of the results of matching.
2121
Route result observers must implement the `RouteResultObserverInterface`:
2222

2323
```php
24-
namespace Zend\Expressive\Router;
24+
namespace Zend\Expressive;
25+
26+
use Zend\Expressive\Router\RouteResult;
2527

2628
interface RouteResultObserverInterface
2729
{
@@ -59,7 +61,7 @@ when invoked, generate a URI.
5961
```php
6062
use Zend\Expressive\Router\RouterInterface;
6163
use Zend\Expressive\Router\RouteResult;
62-
use Zend\Expressive\Router\RouteResultObserverInterface;
64+
use Zend\Expressive\RouteResultObserverInterface;
6365

6466
class UriGenerator implements RouteResultObserverInterface
6567
{

src/Application.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,19 @@ public function any($path, $middleware, $name = null)
176176
/**
177177
* Attach a route result observer.
178178
*
179-
* @param Router\RouteResultObserverInterface $observer
179+
* @param RouteResultObserverInterface $observer
180180
*/
181-
public function attachRouteResultObserver(Router\RouteResultObserverInterface $observer)
181+
public function attachRouteResultObserver(RouteResultObserverInterface $observer)
182182
{
183183
$this->routeResultObservers[] = $observer;
184184
}
185185

186186
/**
187187
* Detach a route result observer.
188188
*
189-
* @param Router\RouteResultObserverInterface $observer
189+
* @param RouteResultObserverInterface $observer
190190
*/
191-
public function detachRouteResultObserver(Router\RouteResultObserverInterface $observer)
191+
public function detachRouteResultObserver(RouteResultObserverInterface $observer)
192192
{
193193
if (false === ($index = array_search($observer, $this->routeResultObservers, true))) {
194194
return;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
6+
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
8+
*/
9+
10+
namespace Zend\Expressive;
11+
12+
use Zend\Expressive\Router\RouteResult;
13+
14+
interface RouteResultObserverInterface
15+
{
16+
/**
17+
* Observe a route result.
18+
*
19+
* @param RouteResult $result
20+
*/
21+
public function update(RouteResult $result);
22+
}

test/RouteMiddlewareTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Zend\Diactoros\ServerRequest;
1717
use Zend\Expressive\Application;
1818
use Zend\Expressive\Router\RouteResult;
19-
use Zend\Expressive\Router\RouteResultObserverInterface;
19+
use Zend\Expressive\RouteResultObserverInterface;
2020
use Zend\Expressive\Router\RouterInterface;
2121

2222
class RouteMiddlewareTest extends TestCase

0 commit comments

Comments
 (0)