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

Routing: debugger panel shows wrong route as matched #1352

Open
stekycz opened this issue Jan 14, 2014 · 6 comments
Open

Routing: debugger panel shows wrong route as matched #1352

stekycz opened this issue Jan 14, 2014 · 6 comments

Comments

@stekycz
Copy link
Contributor

stekycz commented Jan 14, 2014

There is a problem using some custom Nette\Application\Routers\RouteList which has some code using in request matching which needs to be only in some subclass of Nette\Application\Routers\RouteList. For example some global settings of whole route group are used only in the list which are used for, lets say, handling of locale parameter.

There is NO problem with matching and handling request itself because there is some indirect recursion but in debugger panel there is another logic which broke its transparent behavior (recursion is not used). Another logic must be here there is not other way to find all routes (now). How you can see there is no call of match method on the list which then causes that debugger panel shows wrong route as matched.

I have been thinking about it and tried some quick solutions but all did not work as I expected. Any ideas welcome!

@fprochazka
Copy link
Contributor

The point here is, that the Route::match() must be called using the parent RouteList to preserve logic from the RouteList.

foreach ($routeList as $index => $route) {
    $appRequest = $routeList->match($index, $httpRequest);
}

@stekycz
Copy link
Contributor Author

stekycz commented Jan 14, 2014

That is true but when I used only parent then all subroutes were detected and if only route is used then the most general (last) route is used (current solution). I have tried some combination of parent and child route but hierarchy structure can be really deep.

@fprochazka
Copy link
Contributor

Recursion is not a problem, it's simply a feature request to allow call match on concrete route in routelist, and all will be solved.

@stekycz
Copy link
Contributor Author

stekycz commented Jan 14, 2014

I have an idea. In RouteList can be RouteList or Route. What do you think about following modifications?

RouteList::match

...
$appRequest = $route->match($httpRequest);
if ($appRequest !== NULL) {
        $name = $appRequest->getPresenterName();
        if (strncmp($name, 'Nette:', 6)) {
                $appRequest->setPresenterName($this->module . $name);
        }
        if ($route instanceof Route) {
                $this->onMatch($this, $route);
        }
        return $appRequest;
}
...

Related changes would be needed in RoutingPanel::analyse (eg. setup callback to RouteList).

@fprochazka
Copy link
Contributor

Not bad at all!

@stekycz
Copy link
Contributor Author

stekycz commented Jan 15, 2014

I have think about it and it is not so simple. There is a problem you want all basic routes (leafs of tree) to show them in debugger panel so you have depth first strategy in tree traversing. But for correct match in debugger panel you need top based call of method match at the "right time" to be sure use have matched correct route and marked it as matched in data from DF traversing. But you do not know which route exactly have been matched from root of the tree.
I think you need a special iterator here to iterate over basic routes and for each call method match on the root of the tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants