I have created a sub-section of our site where logged in users of a given role can access a set of forums. I have the core forums module enabled.

I want the path of the new forums to respect the subsection paths. ie, rather than /forums/topic/2 it should be /private/discussion/2.

I have used Pathauto to re-write the individual topics and that works fine. But I am having far more problems with the containers and forum list pages.

I have a custom module that manages this section of the site - including custom user routing and permissions. I have created paths to allow for my new format:

mymodule.forum.index:
  path: '/private/discussion'
  defaults:
    _controller: '\Drupal\forum\Controller\ForumController::forumIndex'
    _title: 'Forums'
  requirements:
    _permission: 'access content'

mymodule.forum.page:
  path: '/private/discussion/{taxonomy_term}'
  defaults:
    _controller: '\Drupal\forum\Controller\ForumController::forumPage'
    _title_callback: '\Drupal\taxonomy\Controller\TaxonomyController::termTitle'
  requirements:
    _permission: 'access content'

These "work" when you navigate directly to them but the core forum module does not generate the correct paths in the forum lists it generates. I have tried writing my own 'ForumController' class that extends the base ForumController from core/forums but so far I don't seem to have figured out how to re-write urls without either breaking half the functionality of the forums or having to re-implement the entire core/forum module.

Users will be adding forums, topics and possibly containers in the future so I need a reasonably robust url generating system.

Is there a sane way to do this?

And one other question, is it a bad idea to make a module dependant on a controller from a core module like I have done?