? Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
5 Mar 2018

With the introduction of service providers and the DI container, class overrides should be avoided in extensions. This pr adds the container to the onBeforeExecute plugin event. Like that an extension developer can override the services in the container.

The following code example registers it's own form factory:

public function onBeforeExecute(BeforeExecuteEvent $event)
{
	$event->getContainer()->share(
		FormFactoryInterface::class,
		function (Container $container)
		{
			return new MyAwesomeFormFactory;
		},
		true
	);
}

NOTE:
Not sure if a new event should be created for that, was lazy and did use an existing one.

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 Libraries
avatar laoneo laoneo - change - 5 Mar 2018
The description was changed
avatar laoneo laoneo - edited - 5 Mar 2018
avatar mbabker
mbabker - comment - 5 Mar 2018

Not sure if a new event should be created for that, was lazy and did use an existing one.

Should be fine. As long as the CMS keeps using the onWhatever naming convention then it's clear these are "CMS owned" events. Now if we ever moved to use the events defined in the base Framework classes after joomla-framework/application#76 then we'd want to re-think the event arguments/naming IMO.

avatar laoneo laoneo - change - 6 Mar 2018
Labels Added: ?
avatar wilsonge wilsonge - close - 7 Apr 2018
avatar wilsonge wilsonge - merge - 7 Apr 2018
avatar wilsonge wilsonge - change - 7 Apr 2018
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-04-07 16:36:37
Closed_By wilsonge

Add a Comment

Login with GitHub to post a comment