AutoRouterImproved extendability
In the current state, the AutoRouterImproved is not thought to be replaced by an App-Specific service and to be extended on.
kenjis: Because it is better to implement the interface, not extending the class.
In my case, I need to change the controller & method name which is already implemented in the router.
Re-Implementing the AutoRouterImproved to do that seems kinda ridiculous.
Two approaches come to my mind:
- The specific solution: Use the "parent" routers methods for finding the method and controller name, this prevents duplicate code and allows for a little app-specific behavior.
- The generic solution: Make the auto routers replaceable by app-specific services
- Optional: make both extendable, so we don't have to write ridiculous amounts of code for small changes.
I don't understand what you say.
AutoRouterImproved has no parent class.
I need to change the controller & method name which is already implemented in the router.
You can extend Router now.
If you change the controller & method name in AutoRouterImproved, would it violate the LSP?
How do you change the controller & method name?
AutoRouterImproved has no parent class.
Both auto routers are initialized by the Router, which provides public methods controllerName, methodName
I'm pro using those both methods in both the AutoRouter and the AutoRouterImproved instead of passing the translateURIDashes configuration to the auto routers.
You can extend
Routernow.
Yes, but the changes to controllerName, methodName are ignored by the "new" auto routers
How do you change the controller & method name?
Similar to translate-uri-dashes i am translating them to camel/pascal case instead of snake case
If you change the controller & method name in AutoRouterImproved, would it violate the LSP?
Using the routers public methods controllerName, methodName would assure that all routing is based on the same name translation logic
In my opinion, controllerName() and methodName() in Router should be just getters.
They should just return the properties, should not have any logic.
There are now three routers or route handlers (defined routes, auto routes improved, auto routes legacy). We have a plan to make them stackable. Also devs will be able to add their own routers and remove unneeded one.