? ? Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
14 Jan 2022

Pull Request for pr's #36562, #36629, #36631.

Summary of Changes

As discussed in #36631. It would be better to get the router from a service. Additionally the getRouter function in applications do become deprecated.

A second step would be to turn the language plugin into a service provider plugin and inject the router there. The same goes for the finder extension and the applications.

ping @nibra and @wilsonge

Testing Instructions

  • Create an article
  • Create a blog menu item
  • Enable the language filter plugin
  • Open the front end

Actual result BEFORE applying this Pull Request

All is working.

Expected result AFTER applying this Pull Request

All is working.

avatar laoneo laoneo - open - 14 Jan 2022
avatar laoneo laoneo - change - 14 Jan 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 14 Jan 2022
Category Front End com_finder Libraries Plugins
cfbe216 14 Jan 2022 avatar laoneo cs
avatar laoneo laoneo - change - 14 Jan 2022
Labels Added: ?
avatar Fedik
Fedik - comment - 16 Jan 2022

I would not deprecate it, Web APP still should have it, like it have a Document.
Just add ServiceProvider, and if someone need a specific Router he will pick it from there (like in Route::link()).

Another thing, introducing SiteRouterInterface looks a bit not-intuitive to me, what purpose of it?
I would expect then AdministratorRouterInterface, ApiRouterInterface, CliRouterInterface etc

avatar joeforjoomla
joeforjoomla - comment - 16 Jan 2022

I would not deprecate it, Web APP still should have it, like it have a Document. Just add ServiceProvider, and if someone need a specific Router he will pick it from there (like in Route::link()).

I agree. Just like Document, Session, etc for consistency it should not be deprecated. Otherwise everything should be deprecated. App still should have everything as a shortcut to the container.

avatar laoneo
laoneo - comment - 16 Jan 2022

The app doesn't have a router instance, all it does it forwards the request to Router::getInstance. There is no reason to have a delegating function in the app. So all of this should be deprecated and the router should be injected wherever possible. On a next step the Route class should be deprecated and routing should actually go over the router only which is the available in all views.

I Made only the SiteRouter interface for now as this is what actually mathers if we need other's then we can do them on demand.

avatar laoneo
laoneo - comment - 17 Jan 2022

I agree. Just like Document, Session, etc for consistency it should not be deprecated. Otherwise everything should be deprecated. App still should have everything as a shortcut to the container.

The app should not be a god object with tons of references. Modern apps inject the stuff which are needed. Especially for the router where the router has a reference to the app but not vice versa. And the container should not be abused as a service locator in the application. This is an anti pattern.

90ecacf 22 Jan 2022 avatar laoneo cs
avatar joomla-cms-bot joomla-cms-bot - change - 25 Jan 2022
Category Front End com_finder Libraries Plugins Repository Front End com_finder Libraries Plugins
avatar laoneo laoneo - change - 25 Jan 2022
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 25 Jan 2022
Category Front End com_finder Libraries Plugins Repository Front End com_finder Libraries Plugins
avatar laoneo laoneo - change - 25 Jan 2022
Title
[4] Deprecate getting the router by the app and introduce a service
[4.2] Deprecate getting the router by the app and introduce a service
avatar laoneo laoneo - edited - 25 Jan 2022
avatar laoneo laoneo - change - 4 Feb 2022
Labels Removed: ?
avatar BPBlueprint
BPBlueprint - comment - 8 Mar 2022

I have tested this item successfully on 51cfca4


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36688.

avatar BPBlueprint BPBlueprint - test_item - 8 Mar 2022 - Tested successfully
avatar dgrammatiko
dgrammatiko - comment - 23 Mar 2022

I have tested this item successfully on f6908c0


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36688.

avatar dgrammatiko dgrammatiko - test_item - 23 Mar 2022 - Tested successfully
avatar laoneo laoneo - change - 23 Mar 2022
Status Pending Ready to Commit
avatar laoneo
laoneo - comment - 23 Mar 2022

rtc


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36688.

avatar roland-d
roland-d - comment - 24 Mar 2022

@laoneo This requires another test after the new commit.

@BPBlueprint Could you redo your test again?

avatar laoneo
laoneo - comment - 24 Mar 2022

@roland-d all I did was adding a try/catch block around, nothing more f6908c0

avatar roland-d roland-d - change - 24 Mar 2022
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2022-03-24 15:44:53
Closed_By roland-d
Labels Added: ?
avatar roland-d roland-d - close - 24 Mar 2022
avatar roland-d
roland-d - comment - 24 Mar 2022

Thanks everybody.

avatar joeforjoomla
joeforjoomla - comment - 25 Mar 2022

Pinging @laoneo

Actually this PR is not fully b/c and reliable, given than:

Factory::getContainer()->get('SiteRouter'):

is not the same than:

$this->app::getRouter('Site');

I've noticed that they are 2 separate and different instances of the SiteRouter class.

So given for example that the Joomla core uses the container: Factory::getContainer()->get('SiteRouter'):
but a system plugin still uses $this->app::getRouter('Site'); to attach some build/parse rules:

$router->attachParseRule ( array (
		$this,
		'preProcessParseRule'
), \Joomla\CMS\Router\Router::PROCESS_BEFORE );

The result will be that the preProcessParseRule function of this plugin will never be called.

This implication has potential drawbacks, not sure how it can be solved other than update the code of all extensions to the new container to work on the same instance of the router class.

avatar laoneo
laoneo - comment - 26 Mar 2022

There is an alias missing for the old class names. Can you give #37381 test?

Add a Comment

Login with GitHub to post a comment