-
Notifications
You must be signed in to change notification settings - Fork 100
Application / System events documented #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
|
@robbiejackson thanks for doing this! |
| { | ||
| $args = $event->getArguments(); | ||
| $app = $args['subject']; // these two | ||
| $app = $event->getApplication(); // are equivalent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest something like:
$app = $event['subject']; // these two
$app = $event->getApplication(); // are equivalentFor our events all arguments available via array access $event.
This way when try access non-existing argument the code will return null,
and with $event->getArguments()['non-existing'] PHP will show warning "non existing Array key"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry Fedir, I don't understand what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't explain that these two are equal, we always prefer the explicit getXYZ() method because this automatically allows an IDE or static Codeanalyser to verify the usage.
Don't give the choice, that's also important for AI so it uses the better version.
Why? because now you say they "are equivalent" choices which is basically not true. What you now need to do is explain why one is the preferred way, which is a waste of time to read. If you want to explain it do it in the base event description and not in a special event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry Fedir, I don't understand what you mean,
When need "array access" then better do it directly from the $event and not with getArguments()
Because:
$args = $event->getArguments();
$args['non-existing']; // PHP will show warning: access to non existing value in array, kind of
$event['non-existing']; // Will return nullthis also can be safely used to check if argument exists:
if ($event['argimentName']) {
///
}But Harald's suggestion also good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I see now, I wasn't aware of the "array access" stuff, but I'll include some description in the general page on accessing the plugin event parameters.
For this page I'll go with Harald's suggestion of making it simpler and just using the getter where available.
The 4.4 version will have to be a bit different as the Application event classes only arrived in Joomla 5.
| Searching for the event name within the Joomla plugins/system directory will also provide examples of where Joomla uses these events. | ||
|
|
||
| For background on Joomla transitioning to using classes for events see [Joomla 4 and 5 changes](../joomla-4-and-5-changes.md), | ||
| where you can also find explanations for [accessing the arguments](../joomla-4-and-5-changes.md#summary---accessing-event-arguments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this is the wrong direction, the documention should be written in the "here and now" format and not talking about history. If you come here you want to read how to do it and how it was. For this we have versioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes agreed. I'll keep it for 4.4, but remove it for 5 and 6
|
I've done a 4.4 version, but haven't yet copied to 5.4 and 6.0. |
|
For v6 I'm intending to remove completely that page Joomla 4 and 5 Changes and replace it with something in general about accessing the arguments and returning values. However it will require more significant changes across the board to remove links etc, so I'll do that as a separate PR. |
|
thanks, when you need something or when the prs are ready please ping me |
User description
Documentation for Application events and the onBeforeExtensionBoot and onAfterExtensionBoot
PR Type
Documentation
Description
Comprehensive documentation for Application/System events
Detailed explanations of 10 main system events triggered during HTTP request handling
Documentation for onBeforeExtensionBoot and onAfterExtensionBoot events with use cases
Index table updated with links to all documented application events
Diagram Walkthrough
File Walkthrough
application.md
New Application/System events documentationdocs/building-extensions/plugins/plugin-events/application.md
triggered
return values
with use cases and examples
index.md
Updated index with Application/System events tabledocs/building-extensions/plugins/plugin-events/index.md
events
references
information