When preparing module content, pass the params #23573
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request for Issue # .
Summary of Changes
When using the 'Prepare Content' option in mod_custom, the module params will be passed to the event handler. The 'onContentPrepare' event accepts a params (Registry) object but, for most types of content, none is sent. Why? We actually need this.
Unless there is some good reason why params are not being passed here and in a lot of other cases where they could be, I will expand on this to have them passed in all suitable cases. Also,
JHtmlContent::prepare
does something weird as well. When$params
is not passed (or passed as null), it creates $params as aJObject
and passes it to the plugins. Which is weird because you'd really want aRegistry
there. But worst of all is that most callers of that function do not passnull
but rather''
so then it's not even set as aJObject
, it's just an empty string. So plugins don't know what to expect. It's a mess. I recommend that, when$params
is not aRegistry
, we do$params = new Registry($params);
so that we can always pass a registry to the plugins.Testing Instructions
OK... so to test this I guess you're going to want to create a content plugin that implements
onContentPrepare
and then set one or more modules to prepare content.Expected result
I expect a module which prepares content (or any item which prepares content and has params) to pass its params to the content plugins.
Actual result
As it is, modules which prepare content are not passing their params.
Documentation Changes Required
Maybe