User tests: Successful: Unsuccessful:
I have to excuse myself, but the original interface that I proposed was sub-optimal. I would like to propose this change. The initial idea was to send in the router object each time the method is called and that the rules might even be called statically, but that idea wasn't very good. Instead, the rules are created as objects now and tied to the respective router. The router itself is handed over to the rule when the rule object is instantiated and can then be stored in a member of the object. This allows things to be set up in the constructor, like the lookup table for the menu item when finding out the right Itemid in the preprocess method.
Please review this code and merge it for Joomla 3.4.0. Right now, the code could still be changed.
Labels |
Added:
?
|
Status | Pending | ⇒ | Ready to Commit |
Setting this RTC on review as Hannes states it was going to be new to Joomla 3.4 so no b/c implications and the code isn't being used anywhere
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5234.
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-11-28 15:42:39 |
You are right, I will have to think about this one a bit.
I see where you are going with this. Instead of implementing a rules object that needs to be injected. You could consider using a pub/sub approach ('Don't call use we will call you') for the router and routing rules. The router would need to trigger 4 events :
You could consider using Joomla plugin system and add a 'router' plugin group that developers can leverage to extend the routing in Joomla.
To make everything fully backwards compatible triggering of the events could be done by injecting callbacks. Technically you could inject 4 closure into the router to handle this. Presto, pluggable routing out of the box that would run along side the current system. You would be augmenting the API this way without breaking anything.
-- Just an off the bat idea.
I decided against using the Plugin system since attaching callback rules seems more lightweight to me than invoking the complete plugin management stack here. You will already be able to attach your own rules to the component router via a plugin and onAfterInitialise. Likewise will you be able to remove rules from a component router at that point, in case we decide to force a set of default rules. I'm not 100% sure on that part yet.
Hi Hannes, callbacks are more lightweight indeed. Joomla however isn't about being the fastest. Latest changed to the event system already make it faster then in the 1.5 days. I'm not too worried about speed here. The cleaner the API the easier for developers to extend the code. Extendability always brings a performance tradeoff.
Looking at the language filter plugin this is actually a very good example of a routing plugin and it could benefit from an event driven approach. The system plugin approach works but is a more crude solution.
We discussed this in the JBS and I was told to remove the constructor.