? Success

User tests: Successful: Unsuccessful:

avatar Hackwar
Hackwar
28 Nov 2014

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.

avatar Hackwar Hackwar - open - 28 Nov 2014
avatar jissues-bot jissues-bot - change - 28 Nov 2014
Labels Added: ?
avatar Hackwar
Hackwar - comment - 28 Nov 2014

We discussed this in the JBS and I was told to remove the constructor.

avatar wilsonge
wilsonge - comment - 28 Nov 2014

:+1:

avatar wilsonge wilsonge - change - 28 Nov 2014
Status Pending Ready to Commit
avatar wilsonge
wilsonge - comment - 28 Nov 2014

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.

avatar mbabker mbabker - close - 28 Nov 2014
avatar mbabker mbabker - change - 28 Nov 2014
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2014-11-28 15:42:39
avatar johanjanssens
johanjanssens - comment - 3 Dec 2014

@Hackwar Why does JComponentRouterRulesInterface also have a build() and parse() method ? If it uses the same interface as the router you can argue that it is a router, or that it should extend from the JComponentRouterInterface ?

avatar Hackwar
Hackwar - comment - 3 Dec 2014

You are right, I will have to think about this one a bit.

avatar johanjanssens
johanjanssens - comment - 3 Dec 2014

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 :

  • onBeforeBuildRoute
  • onAfterBuildRoute
  • onBeforeParseRoute
  • onAfterParseRoute

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.

avatar Hackwar
Hackwar - comment - 3 Dec 2014

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.

avatar Hackwar
Hackwar - comment - 3 Dec 2014

You can see that a little bit in the language filter plugin in #5140, where I only attach the rule to remove the &lang= query part when SEF URLs are enabled and with non-SEF URLs it replaces the lang ISO code with the lang SEF code instead.

avatar johanjanssens
johanjanssens - comment - 3 Dec 2014

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.

Add a Comment

Login with GitHub to post a comment