From 3a3f3c98801a74136135b0b31bd92bb90180ef94 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 22 Aug 2022 21:48:48 +0100 Subject: [PATCH] Removes affordance to the deprecated `ModuleRouteListener` in Url helper Ref: https://github.com/laminas/laminas-mvc/pull/123 --- src/Helper/Url.php | 18 +----------------- test/Helper/UrlTest.php | 11 ----------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index 64eeedc..9f04e9c 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -4,7 +4,6 @@ namespace Laminas\Mvc\View\Helper; -use Laminas\Mvc\ModuleRouteListener; use Laminas\Mvc\View\Exception\RouteNotMatchedException; use Laminas\Router\RouteInterface; use Laminas\Router\RouteMatch; @@ -17,7 +16,6 @@ use function is_array; use function is_bool; use function is_object; -use function is_string; final class Url { @@ -71,21 +69,7 @@ public function __invoke( assert(is_array($options)); if ($reuseMatchedParams) { - $routeMatchParams = $this->routeMatch->getParams(); - - /** @var mixed $controller */ - $controller = $routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER] ?? null; - - if (is_string($controller)) { - $routeMatchParams['controller'] = $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($this->routeMatch->getParams(), $params); } $options['name'] = $name; diff --git a/test/Helper/UrlTest.php b/test/Helper/UrlTest.php index 866be47..baa80cc 100644 --- a/test/Helper/UrlTest.php +++ b/test/Helper/UrlTest.php @@ -153,17 +153,6 @@ public function testThatMatchedRouteParamsAreNotReusedByDefault(): void ); } - public function testThatControllerIsSourcedFromModuleRouteListenerWhenAvailable(): void - { - $this->routeMatch->setMatchedRouteName('default'); - $this->routeMatch->setParam(ModuleRouteListener::ORIGINAL_CONTROLLER, 'groovy'); - - self::assertEquals( - '/groovy/bar', - $this->helper->__invoke('default', ['action' => 'bar'], [], true) - ); - } - public function testThatGivenControllerOverridesControllerFoundInModuleRouteListener(): void { $this->routeMatch->setMatchedRouteName('default');