joomla/joomla-cms — pull request #5168 by Hackwar (2014-11-22 20:37:00+00:00)
Title: Routing: using the dependency injected $app and $menu in the core routers

In one of the last routing PRs, the JApplicationCms and JMenu objects were handed over to the constructor of the component routers. This allows to have test-objects be injected into the routers or to change the original objects where necessary.

This PR implements this change in the core routers by modifying the JComponentRouterBase class and subsequently changing the code in the core routers to use the new objects of the class.

I've been trying to decide if this is backwards compatible for a while longer. Not so much because the core routers are slightly changed, but because JComponentRouterBase is changed in that it gets a constructor and that this constructor accepts 2 parameters. If a developer wrote his own router class which extends from JComponentRouterBase and which has its own constructor, but does not call the parent constructor, $this->app and $this->menu would not be available to the router. But then again, those routers would not use $this->app and $this->menu in their code anyway. The only way this could go wrong, would be if a developer extends a core router and has his own constructor written for it, that does not call the parent constructor. This is a VERY unlikely construct and I would say that this is equally possible to winning the lottery and being struck by lightning at the same time. So I think we are safe here. (I'm just trying to cover all our bases here.)

Testing instructions: Apply the change and simply see that nothing is broken.

This was made possible through the generous donation of the people mentioned in the following link via an Indiegogo campaign: http://joomlager.de/crowdfunding/5-contributors