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

Commit 7742df7

Browse files
committed
Have UrlHelper implement RouteResultObserverInterface
Updates UrlHelper to implement RouteResultObserverInterface.
1 parent 752eb5e commit 7742df7

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"require": {
2020
"php": ">=5.5",
2121
"container-interop/container-interop": "^1.1",
22-
"zendframework/zend-expressive": "^1.0@rc",
22+
"zendframework/zend-expressive": "~1.0.0-dev@dev",
2323
"zendframework/zend-filter": "^2.5",
2424
"zendframework/zend-i18n": "^2.5",
2525
"zendframework/zend-servicemanager": "^2.5",

src/UrlHelper.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
use Zend\Expressive\Exception;
1111
use Zend\Expressive\Router\RouterInterface;
1212
use Zend\Expressive\Router\RouteResult;
13+
use Zend\Expressive\Router\RouteResultObserverInterface;
1314
use Zend\View\Helper\AbstractHelper;
1415

15-
class UrlHelper extends AbstractHelper
16+
class UrlHelper extends AbstractHelper implements RouteResultObserverInterface
1617
{
1718
/**
1819
* @var RouteResult
@@ -62,6 +63,14 @@ public function __invoke($route = null, $params = [])
6263
return $this->router->generateUri($route, $params);
6364
}
6465

66+
/**
67+
* {@inheritDoc}
68+
*/
69+
public function update(RouteResult $result)
70+
{
71+
$this->result = $result;
72+
}
73+
6574
/**
6675
* @param RouteResult $result
6776
*/

test/UrlHelperTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Zend\Expressive\Exception;
1515
use Zend\Expressive\Router\RouterInterface;
1616
use Zend\Expressive\Router\RouteResult;
17+
use Zend\Expressive\Router\RouteResultObserverInterface;
1718
use Zend\Expressive\ZendView\UrlHelper;
1819

1920
class UrlHelperTest extends TestCase
@@ -134,4 +135,18 @@ public function testProvidedParametersOverrideAnyPresentInARouteResultWhenGenera
134135

135136
$this->assertEquals('URL', $helper('resource', ['id' => 2]));
136137
}
138+
139+
public function testIsARouteResultObserver()
140+
{
141+
$helper = $this->createHelper();
142+
$this->assertInstanceOf(RouteResultObserverInterface::class, $helper);
143+
}
144+
145+
public function testUpdateMethodSetsRouteResultProperty()
146+
{
147+
$result = $this->prophesize(RouteResult::class);
148+
$helper = $this->createHelper();
149+
$helper->update($result->reveal());
150+
$this->assertAttributeSame($result->reveal(), 'result', $helper);
151+
}
137152
}

0 commit comments

Comments
 (0)