From b0abd6cb7eb133b73728f04ba66c554e24ea72d6 Mon Sep 17 00:00:00 2001 From: SharkyKZ Date: Mon, 12 Dec 2022 09:52:29 +0200 Subject: [PATCH 1/4] Plugin changes --- migrations/44-50/new-deprecations.md | 16 ++++++++++++++++ .../44-50/removed-backward-incompatibility.md | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/migrations/44-50/new-deprecations.md b/migrations/44-50/new-deprecations.md index 3fff1a43..9a38d1bf 100644 --- a/migrations/44-50/new-deprecations.md +++ b/migrations/44-50/new-deprecations.md @@ -10,3 +10,19 @@ All the new deprecations that should be aware of and what you should now be usin This page is unfinished, please use the **Edit this Page** link at the bottom of this page to help make it more useful. ::: + +### Joomla\CMS\Extension\PluginInterface to no longer extend Joomla\Event\DispatcherAwareInterface +In 6.0 `Joomla\CMS\Extension\PluginInterface` will no longer extend `Joomla\Event\DispatcherAwareInterface`. An instance of `Joomla\Event\DispatcherInterface` must be passed to `Joomla\CMS\Extension\PluginInterface::registerListeners()` instead. This applies to `Joomla\CMS\Plugin\CMSPlugin` implementation too. + +### Joomla\CMS\Plugin\CMSPlugin::__construct() to longer accept an instance of Joomla\Event\DispatcherInterface +In 6.0 passing an instance of `Joomla\Event\DispatcherInterface` as first argument to `Joomla\CMS\Plugin\CMSPlugin::__construct()` will not be supported. An instance of `Joomla\Event\DispatcherInterface` must be passed to `Joomla\CMS\Plugin\CMSPlugin::registerListeners()` instead. + +### Joomla\CMS\Plugin\CMSPlugin::registerLegacyListener() and Joomla\CMS\Plugin\CMSPlugin::registerListeners() deprecated +`Joomla\CMS\Plugin\CMSPlugin::registerLegacyListener()` and `Joomla\CMS\Plugin\CMSPlugin::registerListener()` methods are deprecated and will be removed in 6.0. + +### Joomla\CMS\Plugin\PluginHelper::importPlugin() signature change +In 6.0 fourth argument of `Joomla\CMS\Plugin\PluginHelper::importPlugin()` will no longer be optional and will require an instance of `Joomla\Event\DispatcherInterface`. Therefore, preceeding arguments will become mandatory. Method calls must be updated accordingly, for example: + +```php +Joomla\CMS\Plugin\PluginHelper::importPlugin('system', null, true, $dispatcher); +``` diff --git a/migrations/44-50/removed-backward-incompatibility.md b/migrations/44-50/removed-backward-incompatibility.md index 7944c5d0..6de887cc 100644 --- a/migrations/44-50/removed-backward-incompatibility.md +++ b/migrations/44-50/removed-backward-incompatibility.md @@ -37,3 +37,19 @@ class MyModel extends ListModel { ### CSS removals The CSS class ".ie11" was removed [via PR #39018](https://github.com/joomla/joomla-cms/pull/39018) + +### Joomla\CMS\Extension\PluginInterface::registerListeners() signature change +`Joomla\CMS\Extension\PluginInterface::registerListeners()` method signature has been changed to accept an instance of `Joomla\Event\DispatcherInterface`. The argument is made optional to allow plugin developers easily support both 4.0 and 5.0. It will become mandatory in 6.0. + +The signature in implementations must be changed accordingly: +```php +class MyPlugin implements \Joomla\CMS\Extension\PluginInterface +{ + public function registerListeners(?\Joomla\Event\DispatcherInterface $dispatcher = null) + { + // Register listeners with the event dispatcher. + } +} +``` +### Joomla\CMS\Plugin\PluginHelper::import() arguments no longer optional +`Joomla\CMS\Plugin\PluginHelper::import()` arguments are now mandatory. Third argument is no longer nullable and requires an instance of `Joomla\Event\DispatcherInterface`. From 92c4ec7bc0cde16a5a3f2f2a7133d2c20a308b16 Mon Sep 17 00:00:00 2001 From: SharkyKZ Date: Mon, 12 Dec 2022 09:54:52 +0200 Subject: [PATCH 2/4] Add hint --- migrations/44-50/new-deprecations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/44-50/new-deprecations.md b/migrations/44-50/new-deprecations.md index 9a38d1bf..8a5ff51b 100644 --- a/migrations/44-50/new-deprecations.md +++ b/migrations/44-50/new-deprecations.md @@ -18,7 +18,7 @@ In 6.0 `Joomla\CMS\Extension\PluginInterface` will no longer extend `Joomla\Even In 6.0 passing an instance of `Joomla\Event\DispatcherInterface` as first argument to `Joomla\CMS\Plugin\CMSPlugin::__construct()` will not be supported. An instance of `Joomla\Event\DispatcherInterface` must be passed to `Joomla\CMS\Plugin\CMSPlugin::registerListeners()` instead. ### Joomla\CMS\Plugin\CMSPlugin::registerLegacyListener() and Joomla\CMS\Plugin\CMSPlugin::registerListeners() deprecated -`Joomla\CMS\Plugin\CMSPlugin::registerLegacyListener()` and `Joomla\CMS\Plugin\CMSPlugin::registerListener()` methods are deprecated and will be removed in 6.0. +`Joomla\CMS\Plugin\CMSPlugin::registerLegacyListener()` and `Joomla\CMS\Plugin\CMSPlugin::registerListener()` methods are deprecated and will be removed in 6.0. Listeners must be registered with the event dispatcher in the `registerListeners()` method. ### Joomla\CMS\Plugin\PluginHelper::importPlugin() signature change In 6.0 fourth argument of `Joomla\CMS\Plugin\PluginHelper::importPlugin()` will no longer be optional and will require an instance of `Joomla\Event\DispatcherInterface`. Therefore, preceeding arguments will become mandatory. Method calls must be updated accordingly, for example: From af6acfbe8102b60a6e943ff540b3ea0595fea91c Mon Sep 17 00:00:00 2001 From: SharkyKZ Date: Tue, 13 Dec 2022 08:10:55 +0200 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Brian Teeman --- migrations/44-50/new-deprecations.md | 6 +++--- migrations/44-50/removed-backward-incompatibility.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/migrations/44-50/new-deprecations.md b/migrations/44-50/new-deprecations.md index 8a5ff51b..3543611c 100644 --- a/migrations/44-50/new-deprecations.md +++ b/migrations/44-50/new-deprecations.md @@ -12,16 +12,16 @@ This page is unfinished, please use the **Edit this Page** link at the bottom of ::: ### Joomla\CMS\Extension\PluginInterface to no longer extend Joomla\Event\DispatcherAwareInterface -In 6.0 `Joomla\CMS\Extension\PluginInterface` will no longer extend `Joomla\Event\DispatcherAwareInterface`. An instance of `Joomla\Event\DispatcherInterface` must be passed to `Joomla\CMS\Extension\PluginInterface::registerListeners()` instead. This applies to `Joomla\CMS\Plugin\CMSPlugin` implementation too. +In 6.0 `Joomla\CMS\Extension\PluginInterface` will no longer extend `Joomla\Event\DispatcherAwareInterface`. An instance of `Joomla\Event\DispatcherInterface` must be passed to `Joomla\CMS\Extension\PluginInterface::registerListeners()` instead. This applies to the `Joomla\CMS\Plugin\CMSPlugin` implementation too. ### Joomla\CMS\Plugin\CMSPlugin::__construct() to longer accept an instance of Joomla\Event\DispatcherInterface -In 6.0 passing an instance of `Joomla\Event\DispatcherInterface` as first argument to `Joomla\CMS\Plugin\CMSPlugin::__construct()` will not be supported. An instance of `Joomla\Event\DispatcherInterface` must be passed to `Joomla\CMS\Plugin\CMSPlugin::registerListeners()` instead. +In 6.0 passing an instance of `Joomla\Event\DispatcherInterface` as the first argument to `Joomla\CMS\Plugin\CMSPlugin::__construct()` will not be supported. An instance of `Joomla\Event\DispatcherInterface` must be passed to `Joomla\CMS\Plugin\CMSPlugin::registerListeners()` instead. ### Joomla\CMS\Plugin\CMSPlugin::registerLegacyListener() and Joomla\CMS\Plugin\CMSPlugin::registerListeners() deprecated `Joomla\CMS\Plugin\CMSPlugin::registerLegacyListener()` and `Joomla\CMS\Plugin\CMSPlugin::registerListener()` methods are deprecated and will be removed in 6.0. Listeners must be registered with the event dispatcher in the `registerListeners()` method. ### Joomla\CMS\Plugin\PluginHelper::importPlugin() signature change -In 6.0 fourth argument of `Joomla\CMS\Plugin\PluginHelper::importPlugin()` will no longer be optional and will require an instance of `Joomla\Event\DispatcherInterface`. Therefore, preceeding arguments will become mandatory. Method calls must be updated accordingly, for example: +In 6.0 the fourth argument of `Joomla\CMS\Plugin\PluginHelper::importPlugin()` will no longer be optional and will require an instance of `Joomla\Event\DispatcherInterface`. Therefore, preceeding arguments will become mandatory. Method calls must be updated accordingly, for example: ```php Joomla\CMS\Plugin\PluginHelper::importPlugin('system', null, true, $dispatcher); diff --git a/migrations/44-50/removed-backward-incompatibility.md b/migrations/44-50/removed-backward-incompatibility.md index 6de887cc..e357fbb7 100644 --- a/migrations/44-50/removed-backward-incompatibility.md +++ b/migrations/44-50/removed-backward-incompatibility.md @@ -39,7 +39,7 @@ class MyModel extends ListModel { The CSS class ".ie11" was removed [via PR #39018](https://github.com/joomla/joomla-cms/pull/39018) ### Joomla\CMS\Extension\PluginInterface::registerListeners() signature change -`Joomla\CMS\Extension\PluginInterface::registerListeners()` method signature has been changed to accept an instance of `Joomla\Event\DispatcherInterface`. The argument is made optional to allow plugin developers easily support both 4.0 and 5.0. It will become mandatory in 6.0. +`Joomla\CMS\Extension\PluginInterface::registerListeners()` method signature has been changed to accept an instance of `Joomla\Event\DispatcherInterface`. The argument is made optional to allow plugin developers to easily support both 4.0 and 5.0. It will become mandatory in 6.0. The signature in implementations must be changed accordingly: ```php @@ -52,4 +52,4 @@ class MyPlugin implements \Joomla\CMS\Extension\PluginInterface } ``` ### Joomla\CMS\Plugin\PluginHelper::import() arguments no longer optional -`Joomla\CMS\Plugin\PluginHelper::import()` arguments are now mandatory. Third argument is no longer nullable and requires an instance of `Joomla\Event\DispatcherInterface`. +`Joomla\CMS\Plugin\PluginHelper::import()` arguments are now mandatory. The third argument is no longer nullable and requires an instance of `Joomla\Event\DispatcherInterface`. From 9a30fa1658e4f4ea63dd3284c6cbe813b613e30e Mon Sep 17 00:00:00 2001 From: SharkyKZ Date: Tue, 13 Dec 2022 09:23:01 +0200 Subject: [PATCH 4/4] Sync changes --- migrations/44-50/new-deprecations.md | 5 ++++- migrations/44-50/removed-backward-incompatibility.md | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/migrations/44-50/new-deprecations.md b/migrations/44-50/new-deprecations.md index 3543611c..9abb5111 100644 --- a/migrations/44-50/new-deprecations.md +++ b/migrations/44-50/new-deprecations.md @@ -21,8 +21,11 @@ In 6.0 passing an instance of `Joomla\Event\DispatcherInterface` as the first ar `Joomla\CMS\Plugin\CMSPlugin::registerLegacyListener()` and `Joomla\CMS\Plugin\CMSPlugin::registerListener()` methods are deprecated and will be removed in 6.0. Listeners must be registered with the event dispatcher in the `registerListeners()` method. ### Joomla\CMS\Plugin\PluginHelper::importPlugin() signature change -In 6.0 the fourth argument of `Joomla\CMS\Plugin\PluginHelper::importPlugin()` will no longer be optional and will require an instance of `Joomla\Event\DispatcherInterface`. Therefore, preceeding arguments will become mandatory. Method calls must be updated accordingly, for example: +In 6.0 the fourth argument of `Joomla\CMS\Plugin\PluginHelper::importPlugin()` will no longer be optional and will require an instance of `Joomla\Event\DispatcherInterface`. Therefore, preceding arguments will become mandatory. Method calls must be updated accordingly, for example: ```php Joomla\CMS\Plugin\PluginHelper::importPlugin('system', null, true, $dispatcher); ``` + +### Joomla\CMS\Plugin\PluginHelper::import() signature change +In 6.0 the third argument of `Joomla\CMS\Plugin\PluginHelper::import()` will not longer be optional and will require an instance of `Joomla\Event\DispatcherInterface`. Therefore, preceding arguments will become mandatory. diff --git a/migrations/44-50/removed-backward-incompatibility.md b/migrations/44-50/removed-backward-incompatibility.md index e357fbb7..e0fa68db 100644 --- a/migrations/44-50/removed-backward-incompatibility.md +++ b/migrations/44-50/removed-backward-incompatibility.md @@ -51,5 +51,3 @@ class MyPlugin implements \Joomla\CMS\Extension\PluginInterface } } ``` -### Joomla\CMS\Plugin\PluginHelper::import() arguments no longer optional -`Joomla\CMS\Plugin\PluginHelper::import()` arguments are now mandatory. The third argument is no longer nullable and requires an instance of `Joomla\Event\DispatcherInterface`.