Skip to content

Commit

Permalink
Removes affordance to the deprecated ModuleRouteListener in Url helper
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteel committed Aug 22, 2022
1 parent 2d9c73c commit 3a3f3c9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
18 changes: 1 addition & 17 deletions src/Helper/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +16,6 @@
use function is_array;
use function is_bool;
use function is_object;
use function is_string;

final class Url
{
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 0 additions & 11 deletions test/Helper/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 3a3f3c9

Please sign in to comment.