-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[5.3] [Events] Use event classes for System plugins #43637
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0cdc93a
system Accessibility
Fedik faa78e5
system Accessibility
Fedik 78a5377
system ActionLogs
Fedik fd330f0
system fields
Fedik 8c8cb12
system highlight
Fedik 3506275
system Jooa11y
Fedik b9e0b75
system Jooa11y
Fedik dde4cfe
system LanguageCode
Fedik 34bccb9
system ActionLogs
Fedik 21ac26b
system ActionLogs
Fedik 18996fc
system log
Fedik f8258f3
system logout
Fedik 7752d5f
system PrivacyConsent
Fedik afc220c
system Remember
Fedik f356919
system Remember
Fedik 73fc479
system Skipto
Fedik 5d471b3
system stats
Fedik 66c85d1
system log
Fedik 48288cb
fields fix
Fedik ef49bae
Merge branch '5.3-dev' into plg-event-system
Fedik 7ebc5ce
Merge branch '5.3-dev' into plg-event-system
Fedik bf4e1d6
cs
Fedik c6c4e1a
Merge branch '5.3-dev' into plg-event-system
Fedik e2ee18f
Merge branch '5.3-dev' into plg-event-system
laoneo 05fdc6f
update
Fedik fbb7653
cs
Fedik 1a45e65
update
Fedik a017cc5
update
Fedik b663c65
Merge branch '5.3-dev' into plg-event-system
laoneo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
libraries/src/Event/Plugin/System/Stats/GetStatsDataEvent.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Joomla! Content Management System | ||
| * | ||
| * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| namespace Joomla\CMS\Event\Plugin\System\Stats; | ||
|
|
||
| use Joomla\CMS\Event\AbstractImmutableEvent; | ||
| use Joomla\CMS\Event\ReshapeArgumentsAware; | ||
| use Joomla\CMS\Event\Result\ResultAware; | ||
| use Joomla\CMS\Event\Result\ResultAwareInterface; | ||
| use Joomla\CMS\Event\Result\ResultTypeArrayAware; | ||
|
|
||
| // phpcs:disable PSR1.Files.SideEffects | ||
| \defined('_JEXEC') or die; | ||
| // phpcs:enable PSR1.Files.SideEffects | ||
|
|
||
| /** | ||
| * Class for Stats plugin. | ||
| * Example: | ||
| * new GetStatsDataEvent('onEventName', ['context' => 'com_example.example']); | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| class GetStatsDataEvent extends AbstractImmutableEvent implements ResultAwareInterface | ||
| { | ||
| use ReshapeArgumentsAware; | ||
| use ResultAware; | ||
| use ResultTypeArrayAware; | ||
|
|
||
| /** | ||
| * The argument names, in order expected by legacy plugins. | ||
| * | ||
| * @var array | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| * @deprecated __DEPLOY_VERSION__ will be removed in 6.0 | ||
| */ | ||
| protected $legacyArgumentsOrder = ['context']; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @param string $name The event name. | ||
| * @param array $arguments The event arguments. | ||
| * | ||
| * @throws \BadMethodCallException | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function __construct($name, array $arguments = []) | ||
| { | ||
| // Reshape the arguments array to preserve b/c with legacy listeners | ||
| if ($this->legacyArgumentsOrder) { | ||
| $arguments = $this->reshapeArguments($arguments, $this->legacyArgumentsOrder); | ||
| } | ||
|
|
||
| parent::__construct($name, $arguments); | ||
|
|
||
| if (!\array_key_exists('context', $this->arguments)) { | ||
| throw new \BadMethodCallException("Argument 'context' of event {$name} is required but has not been provided"); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Setter for the context argument. | ||
| * | ||
| * @param string $value The value to set | ||
| * | ||
| * @return string | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| protected function onSetContext(string $value): string | ||
| { | ||
| return $value; | ||
| } | ||
|
|
||
| /** | ||
| * Getter for the context argument. | ||
| * | ||
| * @return string | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function getContext(): string | ||
| { | ||
| return $this->arguments['context']; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.