core icon indicating copy to clipboard operation
core copied to clipboard

Dinamic params on routes

Open riv0tril opened this issue 3 years ago • 0 comments

Find an alternative to the following or directly initialize the array as empty since the params are already inside the route object.

https://github.com/mikecao/flight/blob/2df64f37ea76ce98b97ed327c6b1f5ea2a5df2b0/flight/Engine.php#L359

This line generates conflicts when it comes to extracting the params using the method Flight::route('/', array($greeting, 'hello'), true); You will find that the order of the parameters passed into the callback method (in this case 'hello') changes depending on whether there are any params in the request or not.

because of this https://github.com/mikecao/flight/blob/2df64f37ea76ce98b97ed327c6b1f5ea2a5df2b0/flight/Engine.php#L366-L370

Other possible solutions is once the routing proccess is done, set the params into the request object.

If you still can't figure out the scenario, think of an abstract controller where all routes execute the same public method and concrete controllers implement this class.

riv0tril avatar May 12 '22 22:05 riv0tril