? Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
5 Mar 2018

Summary of Changes

Introduces a ModuleDispatcher as replacement for the single entry file for modules. The workflow is then similar to components with a Dispatcher and a service provider.

A module needs then a file services/provider.php which does register the ModuleInterface::class resource in the container:

public function register(Container $container)
{
	$container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Module\\MyModule'));

	$container->registerServiceProvider(new Module);
}

and a dispatcher created by the DispatcherFactory. The dispatcher can override the function getLayoutData() to provide additional data for the layout. The rest stays the same.

More information can be found in #20217 and #19667.

Testing Instructions

Open the front end.

Expected result

The Menu module should work as before.

Actual result

All is working fine.

Documentation Changes Required

Needs to be documented as with the Dispatcher for components.

f21a961 2 Mar 2018 avatar laoneo CS
6b7efe8 2 Mar 2018 avatar laoneo CS
87b884a 2 Mar 2018 avatar laoneo CS
avatar laoneo laoneo - open - 5 Mar 2018
avatar laoneo laoneo - change - 5 Mar 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 5 Mar 2018
Category Administration com_admin com_associations com_banners com_cache com_categories com_checkin com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_modules com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users Front End
avatar laoneo laoneo - change - 5 Mar 2018
Labels Added: ?
avatar shur
shur - comment - 5 Mar 2018

administrator/components/com_content/Dispatcher/Dispatcher.php
Is everything correct here?
Must file name start with the capital letter?

avatar laoneo
laoneo - comment - 5 Mar 2018

Yes, that's the new approach we go, introduced by pr #19811. I will convert the rest of the core extensions when all services like Associations, etc. is done.

avatar joomla-cms-bot joomla-cms-bot - change - 8 May 2018
Category Administration com_admin com_associations com_banners com_cache com_categories com_checkin com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_modules com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users Front End Administration com_admin com_associations com_banners com_cache com_categories com_checkin com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_modules com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users Repository
avatar joomla-cms-bot joomla-cms-bot - change - 23 May 2018
Category Administration com_admin com_associations com_banners com_cache com_categories com_checkin com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_modules com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users Repository Administration com_admin com_associations com_banners com_cache com_categories com_checkin com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users Repository Front End
avatar laoneo laoneo - change - 23 May 2018
The description was changed
avatar laoneo laoneo - edited - 23 May 2018
avatar laoneo laoneo - change - 23 May 2018
The description was changed
avatar laoneo laoneo - edited - 23 May 2018
avatar roland-d
roland-d - comment - 24 May 2018

@laoneo It looks like this PR is polluted as I see component dispatchers as changed files as well while I would expect just module files. Is that correct?

avatar laoneo
laoneo - comment - 24 May 2018

Yes, I had to rename the generic Dispatcher class to ComponentDispatcher as there is now a new ModuleDispatcher.

avatar roland-d
roland-d - comment - 25 May 2018

@laoneo Can you fix the conflict?

avatar joomla-cms-bot joomla-cms-bot - change - 31 May 2018
Category Administration com_admin com_associations com_banners com_cache com_categories com_checkin com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users Repository Front End Administration com_admin com_associations com_banners com_categories com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_languages com_login com_media com_menus com_messages com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_users Repository Front End
avatar laoneo
laoneo - comment - 31 May 2018

@roland-d thanks for the review. Merge conflicts are fixed.

avatar joomla-cms-bot joomla-cms-bot - change - 17 Jul 2018
Category Administration com_admin com_associations com_banners com_categories com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_languages com_login com_media com_menus com_messages com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_users Repository Front End Administration com_admin com_associations com_categories com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_languages com_login com_media com_messages com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_users Repository Front End com_config com_mailto com_modules
avatar mbabker
mbabker - comment - 24 Jul 2018

Modules aren't really designed to be service providers. They're more of a consumer of services from the core libraries or components. So do we really need to support ALL the same types of features as components (i.e. the ability to define services), or can we keep this to only use of the dispatcher system?

Also, keep in mind #8276 since this PR directly affects that issue, and inherently how all modules are rendered today. There are a lot of variables that presently scope creep into modules that need to be accounted for.

avatar rdeutz
rdeutz - comment - 24 Jul 2018

I don't have a better idea just at this moment but this looks a bit over engineered to me. For me Modules are making output that's it. What is the avantage of having a module as a service?

avatar laoneo
laoneo - comment - 25 Jul 2018

At the moment we can just use the dispatcher. But for example com_ajax can then be extended to check for a service and no manual file and class loading. I don't know how you guys feel but I like when there is always one way of doing things. It will be then easier to document it too as devs will have the same concept across all extension types.

At JAB we came up with the conclusion that this can be a first step into the direction to be able to offer component outputs as modules as modules are often just another view for a component.

avatar mbabker
mbabker - comment - 25 Jul 2018

I do think the dispatcher is a step in the right direction (especially if we want to try merging modules and components down the road and be able to support a more HMVC based architecture), I just don't think that modules by design need to be considered service providers as well since by design they are data consumers.

avatar laoneo
laoneo - comment - 25 Jul 2018

just don't think that modules by design need to be considered service providers

In general I agree. So you want to remove the services/provider.php file and manually instantiate the dispatcher in the module helper? While doing all this service provider stuff, I really like the fact that an extension gets back control how it is loaded.

avatar mbabker
mbabker - comment - 25 Jul 2018

Well crap. I don't think we need to hardcode the dispatcher instantiation in the module helper, but I feel like having the service provider file is going to open the door to devs trying to register global services in modules and we don't quite want that to happen (or rather, it should be heavily discouraged because it's a bit more awkward to "boot" a module for this type of thing and IMO that's a sign you're trying to do too much in a module). So maybe we just have to leave it and hope for the best?

avatar laoneo
laoneo - comment - 25 Jul 2018

The DI container, which is passed to the module, is a child container of the global one. So all the dev can do is to register stuff in the child container. The global one is not accessible, except of JFactory::getContainer.

avatar mbabker
mbabker - comment - 25 Jul 2018

We should be OK then (I had to make sure we didn't do something crazy like have a public $container->getParent(), we don't, so we're good).

avatar laoneo
laoneo - comment - 25 Jul 2018

Was double checking the code too about the visibility of the parent variable.

avatar joomla-cms-bot joomla-cms-bot - change - 21 Aug 2018
Category Administration com_admin com_associations com_categories com_config com_contact com_content com_contenthistory com_cpanel com_fields com_finder com_installer com_languages com_login com_media com_messages com_newsfeeds com_plugins com_postinstall com_redirect com_search com_tags com_users Repository Front End com_mailto com_modules Administration com_admin com_associations com_categories com_contact com_content com_contenthistory com_cpanel com_fields com_login com_media com_newsfeeds Repository Front End com_config com_mailto com_modules Libraries
avatar joomla-cms-bot joomla-cms-bot - change - 23 Aug 2018
Category Administration com_admin com_associations com_categories com_config com_contact com_content com_contenthistory com_cpanel com_fields com_login com_media com_newsfeeds Repository Front End com_mailto com_modules Libraries Repository Administration com_associations Front End com_content Libraries Modules
avatar joomla-cms-bot joomla-cms-bot - change - 23 Aug 2018
Category Administration com_associations com_content Repository Front End Libraries Modules Repository Libraries Modules Front End
avatar joomla-cms-bot joomla-cms-bot - change - 31 Aug 2018
Category Repository Front End Libraries Modules Administration com_admin com_associations com_banners com_cache com_checkin com_config com_content com_contenthistory com_cpanel com_csp com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_modules com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users com_workflow
avatar laoneo
laoneo - comment - 31 Aug 2018

I'v renamed the classes and could also get rid of the BasicModule class as the new ModuleDispatcherFactory can now create the new DefaultModule too. For that I had to rename the DispatcherFactory to ComponentDispatcherFactory, which made the pr again bigger. But everything is now clearly separated.

Dispatcher namespace looks now:
image

avatar laoneo
laoneo - comment - 13 Sep 2018

Any more feedback?

avatar roland-d
roland-d - comment - 20 Sep 2018

@laoneo Why is it called DefaultModuleDispatcher.php versus the ComponentDispatcher.php? I would expect a ModuleDispatcher.php?

Other than that, the consistency looks good. This PR is also so huge I think we should just start using it and see if we run into any issues :)

avatar laoneo
laoneo - comment - 20 Sep 2018

Was a suggestion from @wilsonge to have it crystal clear that this is the default one. Having a look now, it would probably make sense to rename it back to ModuleDispatcher.php.

avatar roland-d
roland-d - comment - 20 Sep 2018

@laoneo Just my first thought was why does that have a different name. Makes more sense to me to stick to one naming scheme.

avatar laoneo
laoneo - comment - 24 Sep 2018

Ok, renamed it. Looks indeed more clear.

avatar joomla-cms-bot joomla-cms-bot - change - 24 Sep 2018
Category Administration com_admin com_associations com_banners com_cache com_checkin com_config com_content com_contenthistory com_cpanel com_csp com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_modules com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users com_workflow Administration com_admin com_associations com_banners com_cache com_categories com_checkin com_config com_content com_contenthistory com_cpanel com_csp com_fields com_finder com_installer com_joomlaupdate com_languages com_login com_media com_menus com_messages com_modules com_plugins com_postinstall com_redirect com_search com_tags com_templates com_users com_workflow
avatar roland-d
roland-d - comment - 25 Sep 2018

@laoneo the drone failed??

avatar zero-24
zero-24 - comment - 25 Sep 2018

just rebooted the tests.

avatar laoneo
laoneo - comment - 26 Sep 2018

Drone is failing atm all the time with a user system test. Rebooting doesn't help, the test needs to be fixed.

avatar wilsonge wilsonge - close - 18 Oct 2018
avatar wilsonge wilsonge - merge - 18 Oct 2018
avatar wilsonge wilsonge - change - 18 Oct 2018
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-10-18 10:30:12
Closed_By wilsonge
avatar wilsonge
wilsonge - comment - 18 Oct 2018

Thanks for being so patient on this one!

avatar laoneo
laoneo - comment - 18 Oct 2018

Time brought a couple of good ideas.

Add a Comment

Login with GitHub to post a comment