-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Can't setParams to dispatcher beforeExecuteRoute #15603
Comments
class ControllerBase extends Controller
{
public function beforeExecuteRoute(Dispatcher $dispatcher): void
{
$dispatcher->setParams([1, 2, 3]);
}
}
class IndexController extends ControllerBase
{
public function indexAction()
{
var_dump($this->dispatcher->getParams());
die();
}
}
//array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } |
Sorry, I've not mentioned that |
This happens because in line 335 of
and since then only that variable is used, so any further call of $dispatcher->setParams has no effect, including such call in beforeExecuteRoute callback (in controller or plugin), because setParams modifies this->params not local params variable.
|
Reopening this - Thanks for pointing it out @kirill-voronov |
…dating during dispatch loop
@niden Looks like events firing during |
Case using in controller or dispatcher itself fires before dispatch loop and works fine, but when using events managed way - it fires during dispatch loop and doesnt affects params |
Resolved in #15794 |
Thanks y'all ❤️ |
@kirill-voronov Thank you for finding this. The second PR has tests that confirm that this works as expected. |
Describe the bug
We want to
setParams()
of the dispatcher onbeforeExecuteRoute
event but it have no effect on the method.Expected behavior
An ability to
setParams()
onbeforeExecuteRoute
event.Details
The text was updated successfully, but these errors were encountered: