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

fix: VOL-4642 remove reliance on copy/pasted Laminas 2 code in query routing #51

Merged
merged 2 commits into from
Mar 5, 2024
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
4 changes: 2 additions & 2 deletions config/backend-routes/correspondence.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'options' => [
'route' => 'correspondence[/]',
],
'may_terminate' => true,
'may_terminate' => false,
'child_routes' => [
'single' => RouteConfig::getSingleConfig(
[
Expand All @@ -33,4 +33,4 @@
'GET' => QueryConfig::getConfig(Query\Correspondence\Correspondences::class),
],
]
];
];
2 changes: 1 addition & 1 deletion config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'may_terminate' => false,
'child_routes' => [
'backend' => [
'type' => \Dvsa\Olcs\Transfer\Util\Hostname::class,
'type' => \Laminas\Router\Http\Hostname::class,
'options' => [
'route' => 'olcs-backend'
],
Expand Down
145 changes: 0 additions & 145 deletions src/Router/LaminasRouterHttpQueryV2.php

This file was deleted.

27 changes: 7 additions & 20 deletions src/Router/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,18 @@

namespace Dvsa\Olcs\Transfer\Router;

use Dvsa\Olcs\Transfer\Router\LaminasRouterHttpQueryV2 as LaminasQuery;
use Laminas\Stdlib\RequestInterface as Request;
use Laminas\Router\Http\RouteMatch;
use Laminas\Router\Http\Method;

class Query extends LaminasQuery
class Query extends Method
{
/**
* match(): defined by RouteInterface interface.
*
* @see \Laminas\Router\RouteInterface::match()
* @param Request $request
* @return RouteMatch|null
*/
public function match(Request $request)
public function assemble(array $params = [], array $options = [])
{
if (!method_exists($request, 'getMethod')) {
return null;
}

$requestVerb = strtoupper($request->getMethod());
$mergedParams = array_merge($this->defaults, $params);

if ($requestVerb === 'GET') {
return new RouteMatch($this->defaults);
if (count($mergedParams)) {
$options['uri']->setQuery($mergedParams);
}

return null;
return parent::assemble($params, $options);
}
}
3 changes: 3 additions & 0 deletions src/Router/QueryConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Dvsa\Olcs\Transfer\Router;

use Laminas\Http\Request;

/**
* Query Config
*
Expand All @@ -14,6 +16,7 @@ public static function getConfig($dto)
return [
'type' => \Dvsa\Olcs\Transfer\Router\Query::class,
'options' => [
'verb' => Request::METHOD_GET,
'defaults' => [
'dto' => $dto
]
Expand Down
Loading
Loading