I'm generating the URL inside a controller in a custom module. The URL I generate is to pages on the same site, but not in the module. I want to append an arbitrary number of slugs to the end of the base URL. Some slugs depend on the return values from other API calls, so there's no way to predict how many there are, or what they will be.
I want to generate a
$url variable of the form:
I have tried using:
But cannot figure out how to get the base route for the website from it. Or how to add arbitrary slugs.
This was trivial in Drupal 7 and earlier, but I cannot find how to do it in Drupal 8. In Drupal 8, how do you generate arbitrary internal URLs from a module? What should I be doing?