-
-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix URL generation in various places #123
Comments
I don't now if this issue embrace also utf-8 user names problem. |
@amdad That's an artefact from esoTalk import. We only allow alphanumeric usernames in Flarum for now :) |
For now... ;) |
Currently Flarum's routes are defined in ApiServiceProvider, ForumServiceProvider, and AdminServiceProvider, all of which are only registered on their respective front controller. Thus, on an API request (entry via api.php), we have no knowledge of forum routes. This is problematic because sometimes API requests need to generate URLs to forum routes (e.g. when sending notification/confirmation emails) What needs to be done:
|
I'm planning to make all route collections available to the URL generator, but only parse those routes (for actual routing) that are needed in each section (API, forum, admin). Will do that early next week. |
Spent quite a while looking into the best solution here and ended up going with three separate classes. Thanks to @luceos for the PR that got this rolling (#518). My reasoning is: - The task of routing and URL generation is independent for each section of the app. Take Flarum\Api\Users\IndexAction for example. I don't want to generate a URL to a Flarum route... I specifically want to generate a URL to an API route. So there should be a class with that specific responsibility. - In fact, each URL generator is slightly different, because we need to add a certain prefix to the start (e.g. /api) - This also allows us to get rid of the "flarum.api" prefix on each route's name. - It's still DRY, because they all extend a base class. At the same time, I could see no reason this needed to be "interfaced", so all of the classes are concrete. Goes a long way to fixing #123 - still just a few places left remaining with hardcoded URLs.
Splitting up our front controllers is a great move, but URL generation is problematic in some cases:
The first two are run through api.php, but need to generate forum routes.
The third can be run through index.php (when data is preloaded), but needs to generate an API route for the pagination links.
The Mentions extension also needs to generate forum routes when run via api.php.
@franzliedke how can we handle this?
The text was updated successfully, but these errors were encountered: