We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

reConfigure route in beforeMatch() callback

I want to use beforeMatch() callback to add some parameters into Dispatcher.

$router->add("/(value1)/(value2)/{param3}.+", [
    'controller' => 'search', 
    'action' => 'search',
    'param1'    => 1,
    'param2'    => 2,
])->beforeMatch(function($uri, $route) {
    ///.... some conditions and actions
    $additionalParams = ['addParam1' => 111, 'addParams2' => 222];
    $route->reConfigure($route->getPattern(), array_merge($route->getPaths(), $additionalParams));
});

I see these extra parameters in var_dump($route) inside callback, but after I get "Warning: Illegal offset type in /var/www/phalcon//htdocs/project/public/index.php on line 44"

44: echo $application->handle()->getContent();

I am new, but I think adding aditional params can be done via annotations directly?