Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop ModuleRouteListener support #123

Merged
merged 2 commits into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 1 addition & 12 deletions src/Controller/Plugin/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Laminas\Mvc\Exception\InvalidArgumentException;
use Laminas\Mvc\Exception\RuntimeException;
use Laminas\Mvc\InjectApplicationEventInterface;
use Laminas\Mvc\ModuleRouteListener;
use Laminas\Mvc\MvcEvent;
use Laminas\Router\RouteStackInterface;
use Traversable;
Expand Down Expand Up @@ -89,17 +88,7 @@ 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);
$params = array_merge($routeMatchParams, $params);
}

$options['name'] = $route;
Expand Down
73 changes: 0 additions & 73 deletions src/ModuleRouteListener.php

This file was deleted.

47 changes: 0 additions & 47 deletions test/Controller/Plugin/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
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;
use Laminas\Router\Http\Segment as SegmentRoute;
use Laminas\Router\Http\TreeRouteStack;
use Laminas\Router\Http\Wildcard;
use Laminas\Router\RouteMatch;
use Laminas\Router\SimpleRouteStack;
use LaminasTest\Mvc\Controller\TestAsset\SampleController;
Expand Down Expand Up @@ -148,48 +145,4 @@ public function testCanPassBooleanValueForThirdArgumentToAllowReusingRouteMatche
$url = $this->plugin->fromRoute('replace', ['action' => 'bar'], true);
$this->assertEquals('/foo/bar', $url);
}

public function testRemovesModuleRouteListenerParamsWhenReusingMatchedParameters(): void
{
$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);
}
}
134 changes: 0 additions & 134 deletions test/ModuleRouteListenerTest.php

This file was deleted.

Loading