Skip to content

Commit

Permalink
Fix issue where current url rule appends path param. closes #1885
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Dec 3, 2018
1 parent 9aff29f commit 0302faa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
1 change: 1 addition & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. This projec

### Added

+ [#1885](https://github.com/luyadev/luya/issues/1885) Fix issue where current url rule appends path param.
+ [#1889](https://github.com/luyadev/luya/issues/1889) Add possibility to fetch images that are inserted after lazyLoading is initialised.
+ [#1887](https://github.com/luyadev/luya/issues/1887) Add attribute hints assign option for dynamic model.

Expand Down
36 changes: 14 additions & 22 deletions core/base/ModuleReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ public function getSuffix()
/**
* Determine the default route based on current defaultRoutes or parsedRequested by the UrlManager.
*
* @return array
* @return array An array with
* + route: The path/route to the controller
* + args: If the url has no params, it returns all params from get request.
* + originalArgs: The arguments (params) parsed from the url trogh url manager
*
* @see Related problems and changes:
* + https://github.com/luyadev/luya/issues/1885
* + https://github.com/luyadev/luya/issues/1267
* + https://github.com/luyadev/luya/issues/754
*/
public function getRequestRoute()
{
Expand All @@ -150,30 +158,13 @@ public function getRequestRoute()
$array = [
'route' => $route[0],
'args' => $route[1],
'originalArgs' => $route[1],
];
}
// resolve the current route by the module
$array['route'] = $this->module->resolveRoute($array['route']);
// overload args if none defined with massiv get assigment
if (count($array['args']) === 0) {
/**
* issue: https://github.com/luyadev/luya/issues/754
*
* 01.02.2016: we have to remove the get param overloading, otherwhise we can not guarnte
* to re generate the current url rule. Have to verify why in which case this was needed.
*
* original: $array['args'] = $this->request->get();
* new: do not overload: $array['args'] = [];
*/
$array['args'] = [];
}

/**
* issue: https://github.com/luyadev/luya/issues/754
*
* As the route resolving should not contain empty argument list we overload the $requertRoute['args'] if they are empty
* with the whole get params
*/

// if there are no arguments, all get params are assigned. In order to use the original arguments from parse request use `originalArgs` instead of `args`.
if (empty($array['args'])) {
$array['args'] = $this->request->get();
}
Expand Down Expand Up @@ -210,6 +201,7 @@ public function defaultRoute($controller, $action = null, array $args = [])
$this->_defaultRoute = [
'route' => implode('/', [$this->module->id, $controller, (empty($action)) ? 'index' : $action]),
'args' => $args,
'originalArgs' => $args,
];
}

Expand All @@ -225,7 +217,7 @@ public function getUrlRule()
return [
'module' => $this->module->id,
'route' => $this->module->id . '/' . $request['route'],
'params' => $request['args'],
'params' => $request['originalArgs'],
];
}

Expand Down

0 comments on commit 0302faa

Please sign in to comment.