Show Navigation
Conversation
Notices
-
The current files in mod/ are currently combining two design patterns, the Controller and the Router.
The Controller is the conductor of the page load, it decides which Model to invoke, which display to populate and handles errors and exceptions.
On the other hand, a Router's only job is to match a specific query string (the part of the URL after the domain + install folder) to a specific Controller, which handles the rest.
The current Router mechanism is rather crude, it matches the first part of the query string to a file with the same name in the mod/ directory and that's it.
If we want to move those file to the src/ directory, then we would need a specific Router with explicit rules regarding which query string calls which Controller or Module in src/.
-
That's too abstract for me, I have to admit. Isn't the router/controller currently some code in index.php? So the stuff in /mod belongs to this "Model"?
I had just thought of a mechanism where we just take the significant part of the query string, then we look if we know a class with that name and execute the specific method.
For the beginning we could just translate every file under /mod in a new class. When we are done, we could then think about improving it.
I would like to keep it simple, so that one does not have to guess to see which files are invoked.
-
1) No, Models are methods directly interacting with the database. Ideally, no other method should invoke database functions.
2) This is a good idea, and this is exactly what a Router is.
3) Absolutely, and the good thing about namespaces is that while mod names are short and generic, there's no risk of name collision if they all are in Friendica\Module.
4) Routers can take many forms, and while you are opting for an automatic one, other have a manual list of correspondence between query string and Controller classes. And simply moving module classes to src/ won't add much guesswork to the current system.