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

Commit 3651cb4

Browse files
committed
Updated to use zend-router v3
This patch updates the component to use zend-router 3.0, allowing the removal of the entire `Zend\Mvc\Router` namespace, as well as related factories in the `Zend\Mvc\Service` namespace. Tests were updated to reflect the change. One set of tests, for the url controller plugin, were marked skipped, as they rely on zend-view being updated to use zend-router. TODO ---- - [ ] once zend-view is updated, update the dependencies in this patch. - [ ] experiment with having tests use zend-router as a module/config provider, to see if they can pass.
1 parent 2ed15b6 commit 3651cb4

File tree

97 files changed

+181
-9637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+181
-9637
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
1919
"zendframework/zend-hydrator": "^1.1 || ^2.1",
2020
"zendframework/zend-form": "^2.7",
21+
"zendframework/zend-router": "^3.0",
2122
"zendframework/zend-stdlib": "^2.7.5 || ^3.0",
2223
"zendframework/zend-psr7bridge": "^0.2",
2324
"container-interop/container-interop": "^1.1"
@@ -37,7 +38,6 @@
3738
"zendframework/zend-session": "^2.6.2",
3839
"zendframework/zend-serializer": "^2.6.1",
3940
"zendframework/zend-text": "^2.6",
40-
"zendframework/zend-uri": "^2.5",
4141
"zendframework/zend-validator": "^2.6",
4242
"zendframework/zend-version": "^2.5",
4343
"zendframework/zend-view": "^2.6.3",
@@ -60,7 +60,6 @@
6060
"zendframework/zend-serializer": "Zend\\Serializer component",
6161
"zendframework/zend-session": "Zend\\Session component for FlashMessenger, PRG, and FPRG plugins",
6262
"zendframework/zend-text": "Zend\\Text component",
63-
"zendframework/zend-uri": "Zend\\Uri component",
6463
"zendframework/zend-validator": "Zend\\Validator component",
6564
"zendframework/zend-version": "Zend\\Version component",
6665
"zendframework/zend-view": "Zend\\View component"

composer.lock

Lines changed: 80 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Controller/AbstractRestfulController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,7 @@ public function notFoundAction()
293293
public function dispatch(Request $request, Response $response = null)
294294
{
295295
if (! $request instanceof HttpRequest) {
296-
throw new Exception\InvalidArgumentException(
297-
'Expected an HTTP request');
296+
throw new Exception\InvalidArgumentException('Expected an HTTP request');
298297
}
299298

300299
return parent::dispatch($request, $response);
@@ -316,8 +315,7 @@ public function onDispatch(MvcEvent $e)
316315
* @todo Determine requirements for when route match is missing.
317316
* Potentially allow pulling directly from request metadata?
318317
*/
319-
throw new Exception\DomainException(
320-
'Missing route matches; unsure how to retrieve action');
318+
throw new Exception\DomainException('Missing route matches; unsure how to retrieve action');
321319
}
322320

323321
$request = $e->getRequest();
@@ -535,7 +533,7 @@ public function addHttpMethodHandler($method, /* Callable */ $handler)
535533
* Attempts to see if an identifier was passed in either the URI or the
536534
* query string, returning it if found. Otherwise, returns a boolean false.
537535
*
538-
* @param \Zend\Mvc\Router\RouteMatch $routeMatch
536+
* @param \Zend\Router\RouteMatch $routeMatch
539537
* @param Request $request
540538
* @return false|mixed
541539
*/

src/Controller/Plugin/Forward.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Zend\Mvc\Exception;
1515
use Zend\Mvc\InjectApplicationEventInterface;
1616
use Zend\Mvc\MvcEvent;
17-
use Zend\Mvc\Router\RouteMatch;
17+
use Zend\Router\RouteMatch;
1818
use Zend\Stdlib\CallbackHandler;
1919

2020
class Forward extends AbstractPlugin

src/Controller/Plugin/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Zend\Mvc\InjectApplicationEventInterface;
1616
use Zend\Mvc\ModuleRouteListener;
1717
use Zend\Mvc\MvcEvent;
18-
use Zend\Mvc\Router\RouteStackInterface;
18+
use Zend\Router\RouteStackInterface;
1919

2020
class Url extends AbstractPlugin
2121
{

src/DispatchListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use ArrayObject;
1313
use Zend\EventManager\AbstractListenerAggregate;
1414
use Zend\EventManager\EventManagerInterface;
15+
use Zend\Router\RouteMatch;
1516
use Zend\ServiceManager\Exception\InvalidServiceException;
1617
use Zend\Stdlib\ArrayUtils;
1718

@@ -76,7 +77,7 @@ public function attach(EventManagerInterface $events, $priority = 1)
7677
public function onDispatch(MvcEvent $e)
7778
{
7879
$routeMatch = $e->getRouteMatch();
79-
$controllerName = $routeMatch instanceof Router\RouteMatch
80+
$controllerName = $routeMatch instanceof RouteMatch
8081
? $routeMatch->getParam('controller', 'not-found')
8182
: 'not-found';
8283
$application = $e->getApplication();

src/ModuleRouteListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Zend\EventManager\AbstractListenerAggregate;
1313
use Zend\EventManager\EventManagerInterface;
14+
use Zend\Router\RouteMatch;
1415

1516
class ModuleRouteListener extends AbstractListenerAggregate
1617
{
@@ -42,7 +43,7 @@ public function attach(EventManagerInterface $events, $priority = 1)
4243
public function onRoute(MvcEvent $e)
4344
{
4445
$matches = $e->getRouteMatch();
45-
if (!$matches instanceof Router\RouteMatch) {
46+
if (!$matches instanceof RouteMatch) {
4647
// Can't do anything without a route match
4748
return;
4849
}

src/MvcEvent.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
namespace Zend\Mvc;
1111

1212
use Zend\EventManager\Event;
13+
use Zend\Router\RouteMatch;
14+
use Zend\Router\RouteStackInterface;
1315
use Zend\Stdlib\RequestInterface as Request;
1416
use Zend\Stdlib\ResponseInterface as Response;
1517
use Zend\View\Model\ModelInterface as Model;
@@ -47,12 +49,12 @@ class MvcEvent extends Event
4749
protected $result;
4850

4951
/**
50-
* @var Router\RouteStackInterface
52+
* @var RouteStackInterface
5153
*/
5254
protected $router;
5355

5456
/**
55-
* @var null|Router\RouteMatch
57+
* @var null|RouteMatch
5658
*/
5759
protected $routeMatch;
5860

@@ -87,7 +89,7 @@ public function getApplication()
8789
/**
8890
* Get router
8991
*
90-
* @return Router\RouteStackInterface
92+
* @return RouteStackInterface
9193
*/
9294
public function getRouter()
9395
{
@@ -97,10 +99,10 @@ public function getRouter()
9799
/**
98100
* Set router
99101
*
100-
* @param Router\RouteStackInterface $router
102+
* @param RouteStackInterface $router
101103
* @return MvcEvent
102104
*/
103-
public function setRouter(Router\RouteStackInterface $router)
105+
public function setRouter(RouteStackInterface $router)
104106
{
105107
$this->setParam('router', $router);
106108
$this->router = $router;
@@ -110,7 +112,7 @@ public function setRouter(Router\RouteStackInterface $router)
110112
/**
111113
* Get route match
112114
*
113-
* @return null|Router\RouteMatch
115+
* @return null|RouteMatch
114116
*/
115117
public function getRouteMatch()
116118
{
@@ -120,10 +122,10 @@ public function getRouteMatch()
120122
/**
121123
* Set route match
122124
*
123-
* @param Router\RouteMatch $matches
125+
* @param RouteMatch $matches
124126
* @return MvcEvent
125127
*/
126-
public function setRouteMatch(Router\RouteMatch $matches)
128+
public function setRouteMatch(RouteMatch $matches)
127129
{
128130
$this->setParam('route-match', $matches);
129131
$this->routeMatch = $matches;

0 commit comments

Comments
 (0)