Override an existing route in a module with ZF3

Hello,

Is there a way to dynamicaly (routes names are variables) override an existing route in a module ?

Thanks for your help.

Franck.

Hello,

Here is my solution :

$router = $this->getServiceLocator()->get('Router');
$route = $config['router']['routes']['myroute'];

// Changes on original route
$route['type'] = \Zend\Router\Http\Hostname::class;
$route['options']['route'] = ':subdomaine.'.gethostname();

// Apply changes
$router->addRoute('myroute', $route);

Franck