Skip to content

Commit

Permalink
Drop ModuleRouteListener support
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksei <[email protected]>
  • Loading branch information
Xerkus committed Jun 3, 2022
1 parent fb59173 commit 3fd6655
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 360 deletions.
1 change: 0 additions & 1 deletion docs/book/mvc-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ priority):

Class | Priority | Method Called | Triggers | Description
-------------------------------|---------:|---------------|----------|------------
`Laminas\Mvc\ModuleRouteListener` | 1 | `onRoute` | none | Determines if the module namespace should be prepended to the controller name. This is the case if the route match contains a parameter key matching the `MODULE_NAMESPACE` constant.
`Laminas\Mvc\RouteListener` | 1 | `onRoute` | `MvcEvent::EVENT_DISPATCH_ERROR` (if no route is matched) | Tries to match the request to the router and return a `RouteMatch` object.

### Triggered By
Expand Down
11 changes: 0 additions & 11 deletions src/Controller/Plugin/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Laminas\EventManager\EventInterface;
use Laminas\Mvc\Exception;
use Laminas\Mvc\InjectApplicationEventInterface;
use Laminas\Mvc\ModuleRouteListener;
use Laminas\Mvc\MvcEvent;
use Laminas\Router\RouteStackInterface;
use Traversable;
Expand Down Expand Up @@ -79,16 +78,6 @@ public function fromRoute($route = null, $params = [], $options = [], $reuseMatc

if ($reuseMatchedParams && $matches) {
$routeMatchParams = $matches->getParams();

if (isset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) {
$routeMatchParams['controller'] = $routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER];
unset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER]);
}

if (isset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE])) {
unset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE]);
}

$params = array_merge($routeMatchParams, $params);
}

Expand Down
69 changes: 0 additions & 69 deletions src/ModuleRouteListener.php

This file was deleted.

48 changes: 0 additions & 48 deletions test/Controller/Plugin/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Laminas\Mvc\Controller\Plugin\Url as UrlPlugin;
use Laminas\Mvc\Exception\DomainException;
use Laminas\Mvc\Exception\RuntimeException;
use Laminas\Mvc\ModuleRouteListener;
use Laminas\Mvc\MvcEvent;
use Laminas\Router\Http\Literal as LiteralRoute;
use Laminas\Router\Http\Segment;
Expand Down Expand Up @@ -145,51 +144,4 @@ public function testCanPassBooleanValueForThirdArgumentToAllowReusingRouteMatche
$url = $this->plugin->fromRoute('replace', ['action' => 'bar'], true);
$this->assertEquals('/foo/bar', $url);
}

/**
*
*/
public function testRemovesModuleRouteListenerParamsWhenReusingMatchedParameters()
{
$router = new TreeRouteStack;
$router->addRoute('default', [
'type' => Segment::class,
'options' => [
'route' => '/:controller/:action',
'defaults' => [
ModuleRouteListener::MODULE_NAMESPACE => 'LaminasTest\Mvc\Controller\TestAsset',
'controller' => 'SampleController',
'action' => 'Dash'
]
],
'child_routes' => [
'wildcard' => [
'type' => Wildcard::class,
'options' => [
'param_delimiter' => '=',
'key_value_delimiter' => '%'
]
]
]
]);

$routeMatch = new RouteMatch([
ModuleRouteListener::MODULE_NAMESPACE => 'LaminasTest\Mvc\Controller\TestAsset',
'controller' => 'Rainbow'
]);
$routeMatch->setMatchedRouteName('default/wildcard');

$event = new MvcEvent();
$event->setRouter($router)
->setRouteMatch($routeMatch);

$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->onRoute($event);

$controller = new SampleController();
$controller->setEvent($event);
$url = $controller->plugin('url')->fromRoute('default/wildcard', ['Twenty' => 'Cooler'], true);

$this->assertEquals('/Rainbow/Dash=Twenty%Cooler', $url);
}
}
132 changes: 0 additions & 132 deletions test/ModuleRouteListenerTest.php

This file was deleted.

Loading

0 comments on commit 3fd6655

Please sign in to comment.