Two possible approaches to do this change in a upgrade safe way.
Option 1. Full module_routing.yaml override
- create a file called
extensions/<my-ext>/config/module_routing.yaml
- Copy the full content of core
module_routing.yaml
to the new file - Do the changes you need
Option 2. Override just the modules you want
- create a file called
extensions/<my-ext>/config/module_routing.php
- Use php code to just update the entries you want, something like:
<?php
use Symfony\Component\DependencyInjection\Container;
if (!isset($container)) {
return;
}
/** @var Container $container */
$routes = $container->getParameter('legacy.module_routing');
if (!isset($routes['accounts'])) {
$routes['accounts'] = [];
}
// do the changes you want to routes accounts
// $routes['accounts'] ...
//set the routes again
$container->setParameter('legacy.module_routing', $routes);