From cf95577d87587ec073820bc16ef9692641066c0a Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 28 Apr 2024 11:21:29 +0300 Subject: [PATCH 01/16] Deprecate registerListeners method --- libraries/src/Extension/PluginInterface.php | 4 ++++ libraries/src/Plugin/CMSPlugin.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libraries/src/Extension/PluginInterface.php b/libraries/src/Extension/PluginInterface.php index 55baeb78188ed..828e2d9600f15 100644 --- a/libraries/src/Extension/PluginInterface.php +++ b/libraries/src/Extension/PluginInterface.php @@ -28,6 +28,10 @@ interface PluginInterface extends DispatcherAwareInterface * @return void * * @since 4.0.0 + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement SubscriberInterface. + * These plugins will be added to dispatcher in PluginHelper::import(). */ public function registerListeners(); } diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index 0666323886331..7e3bfb949c56d 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -200,6 +200,10 @@ public function loadLanguage($extension = '', $basePath = JPATH_ADMINISTRATOR) * @return void * * @since 4.0.0 + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement SubscriberInterface. + * These plugins will be added to dispatcher in PluginHelper::import(). */ public function registerListeners() { @@ -210,6 +214,8 @@ public function registerListeners() return; } + @trigger_error('The plugin should implement SubscriberInterface.', E_USER_DEPRECATED); + $reflectedObject = new \ReflectionObject($this); $methods = $reflectedObject->getMethods(\ReflectionMethod::IS_PUBLIC); @@ -265,6 +271,9 @@ public function registerListeners() * @return void * * @since 4.0.0 + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement SubscriberInterface. */ final protected function registerLegacyListener(string $methodName) { @@ -313,6 +322,9 @@ function (AbstractEvent $event) use ($methodName) { * @return void * * @since 4.0.0 + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement SubscriberInterface. */ final protected function registerListener(string $methodName) { @@ -327,6 +339,9 @@ final protected function registerListener(string $methodName) * @return boolean * * @since 4.0.0 + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement SubscriberInterface. */ private function parameterImplementsEventInterface(\ReflectionParameter $parameter): bool { From 614c6a832d1cd0756a6f5efb73ef21577dad36ab Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 28 Apr 2024 11:40:43 +0300 Subject: [PATCH 02/16] Deprecate use of use DispatcherAwareInterface --- libraries/src/Extension/PluginInterface.php | 2 ++ libraries/src/Plugin/CMSPlugin.php | 33 +++++++++++++++------ libraries/src/Plugin/PluginHelper.php | 2 ++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/libraries/src/Extension/PluginInterface.php b/libraries/src/Extension/PluginInterface.php index 828e2d9600f15..fd6952febca0f 100644 --- a/libraries/src/Extension/PluginInterface.php +++ b/libraries/src/Extension/PluginInterface.php @@ -19,6 +19,8 @@ * Access to plugin specific services. * * @since 4.0.0 + * + * @TODO Starting from 7.0 the class will no longer extend DispatcherAwareInterface */ interface PluginInterface extends DispatcherAwareInterface { diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index 7e3bfb949c56d..4b18da1b329b8 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -32,6 +32,8 @@ * Plugin Class * * @since 1.5 + * + * @TODO Starting from 7.0 the class will no longer implement DispatcherAwareInterface and LanguageAwareInterface */ abstract class CMSPlugin implements DispatcherAwareInterface, PluginInterface, LanguageAwareInterface { @@ -101,15 +103,31 @@ abstract class CMSPlugin implements DispatcherAwareInterface, PluginInterface, L /** * Constructor * - * @param DispatcherInterface $dispatcher The event dispatcher - * @param array $config An optional associative array of configuration settings. - * Recognized key values include 'name', 'group', 'params', 'language' - * (this list is not meant to be comprehensive). + * @param array $config An optional associative array of configuration settings. + * Recognized key values include 'name', 'group', 'params', 'language' + * (this list is not meant to be comprehensive). * * @since 1.5 */ - public function __construct(DispatcherInterface $dispatcher, array $config = []) + public function __construct($config = []) { + if ($config instanceof DispatcherInterface) { + @trigger_error( + sprintf( + 'Passing an instance of %1$s to %2$s() will not be supported in 7.0. ' + . 'Starting from 7.0 CMSPlugin class will no longer implement DispatcherAwareInterface.', + DispatcherInterface::class, + __METHOD__ + ), + \E_USER_DEPRECATED + ); + + // Set the dispatcher we are to register our listeners with + $this->setDispatcher($config); + + $config = func_num_args() > 1 ? func_get_arg(1) : []; + } + // Get the parameters. if (isset($config['params'])) { if ($config['params'] instanceof Registry) { @@ -153,9 +171,6 @@ public function __construct(DispatcherInterface $dispatcher, array $config = []) $this->db = Factory::getDbo(); } } - - // Set the dispatcher we are to register our listeners with - $this->setDispatcher($dispatcher); } /** @@ -214,7 +229,7 @@ public function registerListeners() return; } - @trigger_error('The plugin should implement SubscriberInterface.', E_USER_DEPRECATED); + @trigger_error('The plugin should implement SubscriberInterface.', \E_USER_DEPRECATED); $reflectedObject = new \ReflectionObject($this); $methods = $reflectedObject->getMethods(\ReflectionMethod::IS_PUBLIC); diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index 9c3c591e311ae..b255b43110e43 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -231,6 +231,7 @@ protected static function import($plugin, $autocreate = true, DispatcherInterfac $plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type); + // @TODO: Starting from 7.0 the CMSPlugin class will no longer use DispatcherAwareInterface if ($dispatcher && $plugin instanceof DispatcherAwareInterface) { $plugin->setDispatcher($dispatcher); } @@ -239,6 +240,7 @@ protected static function import($plugin, $autocreate = true, DispatcherInterfac return; } + // @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin); $plugin->registerListeners(); } From 33d0394e7af3dbe34c6095c73a6a44b346d2322b Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 28 Apr 2024 11:55:18 +0300 Subject: [PATCH 03/16] Deprecate use of use DispatcherAwareInterface --- libraries/src/Plugin/PluginHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index b255b43110e43..4c0c2c75a3f89 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -240,7 +240,7 @@ protected static function import($plugin, $autocreate = true, DispatcherInterfac return; } - // @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin); + // @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin);, for plugins which implements SubscriberInterface. $plugin->registerListeners(); } From 7d65887293d10d3d10b4a975b5e4e7f89977becc Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 28 Apr 2024 12:07:07 +0300 Subject: [PATCH 04/16] Deprecate use of use DispatcherAwareInterface --- libraries/src/Plugin/CMSPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index 4b18da1b329b8..e268fd99127b5 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -125,7 +125,7 @@ public function __construct($config = []) // Set the dispatcher we are to register our listeners with $this->setDispatcher($config); - $config = func_num_args() > 1 ? func_get_arg(1) : []; + $config = \func_num_args() > 1 ? \func_get_arg(1) : []; } // Get the parameters. From a54943acc7ac134f80983ac2c34d0d9483cb2c47 Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 28 Apr 2024 12:19:28 +0300 Subject: [PATCH 05/16] Deprecate use of use DispatcherAwareInterface --- libraries/src/Plugin/CMSPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index e268fd99127b5..6a965a2533d7b 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -125,7 +125,7 @@ public function __construct($config = []) // Set the dispatcher we are to register our listeners with $this->setDispatcher($config); - $config = \func_num_args() > 1 ? \func_get_arg(1) : []; + $config = \func_num_args() > 1 ? func_get_arg(1) : []; } // Get the parameters. From ad7dbb481b681eb51f0b022e1c07a76cb21a84ad Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 5 May 2024 14:06:08 +0300 Subject: [PATCH 06/16] Message about deprecation --- libraries/src/Plugin/CMSPlugin.php | 46 ++++++++++++++++++++++++++- libraries/src/Plugin/PluginHelper.php | 1 - 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index 6a965a2533d7b..b986b7855fa8e 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -14,6 +14,7 @@ use Joomla\CMS\Event\Result\ResultAwareInterface; use Joomla\CMS\Extension\PluginInterface; use Joomla\CMS\Factory; +use Joomla\CMS\Language\Language; use Joomla\CMS\Language\LanguageAwareInterface; use Joomla\CMS\Language\LanguageAwareTrait; use Joomla\Event\AbstractEvent; @@ -38,7 +39,10 @@ abstract class CMSPlugin implements DispatcherAwareInterface, PluginInterface, LanguageAwareInterface { use DispatcherAwareTrait; - use LanguageAwareTrait; + use LanguageAwareTrait { + setLanguage as traitSetLanguage; + getLanguage as traitGetLanguage; + } /** * A Registry object holding the parameters for the plugin @@ -420,4 +424,44 @@ public function setApplication(CMSApplicationInterface $application): void $this->setLanguage($application->getLanguage()); } } + + /** + * Set the language to use. + * + * @param Language $language The language to use + * + * @return void + * + * @since __DEPLOY_VERSION__ + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement LanguageAwareInterface on its own, when it is needed. + */ + public function setLanguage(Language $language): void + { + $this->traitSetLanguage($language); + } + + /** + * Get the Language. + * + * @return Language + * + * @throws \UnexpectedValueException May be thrown if the language has not been set. + * + * @since __DEPLOY_VERSION__ + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement LanguageAwareInterface on its own, when it is needed. + */ + protected function getLanguage(): Language + { + @trigger_error( + 'Use of LanguageAwareInterface over CMSPlugin will be removed in 7.0.' + . ' Plugin should implement LanguageAwareInterface on its own, when it is needed.', + \E_USER_DEPRECATED + ); + + return $this->traitGetLanguage(); + } } diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index 4c0c2c75a3f89..c5de5c142e38f 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -231,7 +231,6 @@ protected static function import($plugin, $autocreate = true, DispatcherInterfac $plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type); - // @TODO: Starting from 7.0 the CMSPlugin class will no longer use DispatcherAwareInterface if ($dispatcher && $plugin instanceof DispatcherAwareInterface) { $plugin->setDispatcher($dispatcher); } From 1991db1708750625e6a5185c1948b6619e54b9e5 Mon Sep 17 00:00:00 2001 From: Fedik Date: Mon, 6 May 2024 14:38:59 +0300 Subject: [PATCH 07/16] Message about deprecation --- libraries/src/Plugin/CMSPlugin.php | 47 ++++++++++++++++++- .../content/finder/src/Extension/Finder.php | 6 ++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index b986b7855fa8e..7c68ca2b37a8b 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -38,7 +38,10 @@ */ abstract class CMSPlugin implements DispatcherAwareInterface, PluginInterface, LanguageAwareInterface { - use DispatcherAwareTrait; + use DispatcherAwareTrait { + setDispatcher as traitSetDispatcher; + getDispatcher as traitGetDispatcher; + } use LanguageAwareTrait { setLanguage as traitSetLanguage; getLanguage as traitGetLanguage; @@ -457,11 +460,51 @@ public function setLanguage(Language $language): void protected function getLanguage(): Language { @trigger_error( - 'Use of LanguageAwareInterface over CMSPlugin will be removed in 7.0.' + __CLASS__ . ': Use of LanguageAwareInterface over CMSPlugin will be removed in 7.0.' . ' Plugin should implement LanguageAwareInterface on its own, when it is needed.', \E_USER_DEPRECATED ); return $this->traitGetLanguage(); } + + /** + * Set the dispatcher to use. + * + * @param DispatcherInterface $dispatcher The dispatcher to use. + * + * @return $this + * + * @since __DEPLOY_VERSION__ + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement DispatcherAwareInterface on its own, when it is needed. + */ + public function setDispatcher(DispatcherInterface $dispatcher) + { + @trigger_error( + __CLASS__ . ': Use of DispatcherAwareInterface over CMSPlugin will be removed in 7.0.' + . ' Plugin should implement DispatcherAwareInterface on its own, when it is needed.', + \E_USER_DEPRECATED + ); + + return $this->traitSetDispatcher($dispatcher); + } + + /** + * Get the event dispatcher. + * + * @return DispatcherInterface + * + * @throws \UnexpectedValueException May be thrown if the dispatcher has not been set. + * + * @since __DEPLOY_VERSION__ + * + * @deprecated 5.2 will be removed in 7.0 + * Plugin should implement DispatcherAwareInterface on its own, when it is needed. + */ + public function getDispatcher() + { + return $this->traitGetDispatcher(); + } } diff --git a/plugins/content/finder/src/Extension/Finder.php b/plugins/content/finder/src/Extension/Finder.php index 83f44d9dbe2b3..6e88a03d36edf 100644 --- a/plugins/content/finder/src/Extension/Finder.php +++ b/plugins/content/finder/src/Extension/Finder.php @@ -13,6 +13,8 @@ use Joomla\CMS\Event\Finder as FinderEvent; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Plugin\PluginHelper; +use Joomla\Event\DispatcherAwareInterface; +use Joomla\Event\DispatcherAwareTrait; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -23,8 +25,10 @@ * * @since 2.5 */ -final class Finder extends CMSPlugin +final class Finder extends CMSPlugin implements DispatcherAwareInterface { + use DispatcherAwareTrait; + /** * Flag to check whether finder plugins already imported. * From e6f50f0133bdca0a75e9fe82c425ab86463a8be6 Mon Sep 17 00:00:00 2001 From: Fedik Date: Wed, 8 May 2024 12:08:23 +0300 Subject: [PATCH 08/16] Clean up --- libraries/src/Extension/PluginInterface.php | 2 - libraries/src/Plugin/CMSPlugin.php | 122 ++---------------- .../content/finder/src/Extension/Finder.php | 6 +- 3 files changed, 11 insertions(+), 119 deletions(-) diff --git a/libraries/src/Extension/PluginInterface.php b/libraries/src/Extension/PluginInterface.php index fd6952febca0f..828e2d9600f15 100644 --- a/libraries/src/Extension/PluginInterface.php +++ b/libraries/src/Extension/PluginInterface.php @@ -19,8 +19,6 @@ * Access to plugin specific services. * * @since 4.0.0 - * - * @TODO Starting from 7.0 the class will no longer extend DispatcherAwareInterface */ interface PluginInterface extends DispatcherAwareInterface { diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index 7c68ca2b37a8b..3cac8018d584a 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -14,7 +14,6 @@ use Joomla\CMS\Event\Result\ResultAwareInterface; use Joomla\CMS\Extension\PluginInterface; use Joomla\CMS\Factory; -use Joomla\CMS\Language\Language; use Joomla\CMS\Language\LanguageAwareInterface; use Joomla\CMS\Language\LanguageAwareTrait; use Joomla\Event\AbstractEvent; @@ -33,19 +32,11 @@ * Plugin Class * * @since 1.5 - * - * @TODO Starting from 7.0 the class will no longer implement DispatcherAwareInterface and LanguageAwareInterface */ abstract class CMSPlugin implements DispatcherAwareInterface, PluginInterface, LanguageAwareInterface { - use DispatcherAwareTrait { - setDispatcher as traitSetDispatcher; - getDispatcher as traitGetDispatcher; - } - use LanguageAwareTrait { - setLanguage as traitSetLanguage; - getLanguage as traitGetLanguage; - } + use DispatcherAwareTrait; + use LanguageAwareTrait; /** * A Registry object holding the parameters for the plugin @@ -110,31 +101,15 @@ abstract class CMSPlugin implements DispatcherAwareInterface, PluginInterface, L /** * Constructor * - * @param array $config An optional associative array of configuration settings. - * Recognized key values include 'name', 'group', 'params', 'language' - * (this list is not meant to be comprehensive). + * @param DispatcherInterface $dispatcher The event dispatcher + * @param array $config An optional associative array of configuration settings. + * Recognized key values include 'name', 'group', 'params', 'language' + * (this list is not meant to be comprehensive). * * @since 1.5 */ - public function __construct($config = []) + public function __construct(DispatcherInterface $dispatcher, array $config = []) { - if ($config instanceof DispatcherInterface) { - @trigger_error( - sprintf( - 'Passing an instance of %1$s to %2$s() will not be supported in 7.0. ' - . 'Starting from 7.0 CMSPlugin class will no longer implement DispatcherAwareInterface.', - DispatcherInterface::class, - __METHOD__ - ), - \E_USER_DEPRECATED - ); - - // Set the dispatcher we are to register our listeners with - $this->setDispatcher($config); - - $config = \func_num_args() > 1 ? func_get_arg(1) : []; - } - // Get the parameters. if (isset($config['params'])) { if ($config['params'] instanceof Registry) { @@ -178,6 +153,9 @@ public function __construct($config = []) $this->db = Factory::getDbo(); } } + + // Set the dispatcher we are to register our listeners with + $this->setDispatcher($dispatcher); } /** @@ -427,84 +405,4 @@ public function setApplication(CMSApplicationInterface $application): void $this->setLanguage($application->getLanguage()); } } - - /** - * Set the language to use. - * - * @param Language $language The language to use - * - * @return void - * - * @since __DEPLOY_VERSION__ - * - * @deprecated 5.2 will be removed in 7.0 - * Plugin should implement LanguageAwareInterface on its own, when it is needed. - */ - public function setLanguage(Language $language): void - { - $this->traitSetLanguage($language); - } - - /** - * Get the Language. - * - * @return Language - * - * @throws \UnexpectedValueException May be thrown if the language has not been set. - * - * @since __DEPLOY_VERSION__ - * - * @deprecated 5.2 will be removed in 7.0 - * Plugin should implement LanguageAwareInterface on its own, when it is needed. - */ - protected function getLanguage(): Language - { - @trigger_error( - __CLASS__ . ': Use of LanguageAwareInterface over CMSPlugin will be removed in 7.0.' - . ' Plugin should implement LanguageAwareInterface on its own, when it is needed.', - \E_USER_DEPRECATED - ); - - return $this->traitGetLanguage(); - } - - /** - * Set the dispatcher to use. - * - * @param DispatcherInterface $dispatcher The dispatcher to use. - * - * @return $this - * - * @since __DEPLOY_VERSION__ - * - * @deprecated 5.2 will be removed in 7.0 - * Plugin should implement DispatcherAwareInterface on its own, when it is needed. - */ - public function setDispatcher(DispatcherInterface $dispatcher) - { - @trigger_error( - __CLASS__ . ': Use of DispatcherAwareInterface over CMSPlugin will be removed in 7.0.' - . ' Plugin should implement DispatcherAwareInterface on its own, when it is needed.', - \E_USER_DEPRECATED - ); - - return $this->traitSetDispatcher($dispatcher); - } - - /** - * Get the event dispatcher. - * - * @return DispatcherInterface - * - * @throws \UnexpectedValueException May be thrown if the dispatcher has not been set. - * - * @since __DEPLOY_VERSION__ - * - * @deprecated 5.2 will be removed in 7.0 - * Plugin should implement DispatcherAwareInterface on its own, when it is needed. - */ - public function getDispatcher() - { - return $this->traitGetDispatcher(); - } } diff --git a/plugins/content/finder/src/Extension/Finder.php b/plugins/content/finder/src/Extension/Finder.php index 6e88a03d36edf..83f44d9dbe2b3 100644 --- a/plugins/content/finder/src/Extension/Finder.php +++ b/plugins/content/finder/src/Extension/Finder.php @@ -13,8 +13,6 @@ use Joomla\CMS\Event\Finder as FinderEvent; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Plugin\PluginHelper; -use Joomla\Event\DispatcherAwareInterface; -use Joomla\Event\DispatcherAwareTrait; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -25,10 +23,8 @@ * * @since 2.5 */ -final class Finder extends CMSPlugin implements DispatcherAwareInterface +final class Finder extends CMSPlugin { - use DispatcherAwareTrait; - /** * Flag to check whether finder plugins already imported. * From 21ed5c72525216c3e200cfa7c53a986b8adbc126 Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 2 Mar 2025 17:19:28 +0200 Subject: [PATCH 09/16] version --- libraries/src/Extension/PluginInterface.php | 2 +- libraries/src/Plugin/CMSPlugin.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/src/Extension/PluginInterface.php b/libraries/src/Extension/PluginInterface.php index fd6952febca0f..5c56d9d73c0e5 100644 --- a/libraries/src/Extension/PluginInterface.php +++ b/libraries/src/Extension/PluginInterface.php @@ -31,7 +31,7 @@ interface PluginInterface extends DispatcherAwareInterface * * @since 4.0.0 * - * @deprecated 5.2 will be removed in 7.0 + * @deprecated __DEPLOY_VERSION__ will be removed in 7.0 * Plugin should implement SubscriberInterface. * These plugins will be added to dispatcher in PluginHelper::import(). */ diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index e7598ecff1b7e..48bf320502799 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -223,7 +223,7 @@ public function loadLanguage($extension = '', $basePath = JPATH_ADMINISTRATOR) * * @since 4.0.0 * - * @deprecated 5.2 will be removed in 7.0 + * @deprecated __DEPLOY_VERSION__ will be removed in 7.0 * Plugin should implement SubscriberInterface. * These plugins will be added to dispatcher in PluginHelper::import(). */ @@ -294,7 +294,7 @@ public function registerListeners() * * @since 4.0.0 * - * @deprecated 5.2 will be removed in 7.0 + * @deprecated __DEPLOY_VERSION__ will be removed in 7.0 * Plugin should implement SubscriberInterface. */ final protected function registerLegacyListener(string $methodName) @@ -345,7 +345,7 @@ function (AbstractEvent $event) use ($methodName) { * * @since 4.0.0 * - * @deprecated 5.2 will be removed in 7.0 + * @deprecated __DEPLOY_VERSION__ will be removed in 7.0 * Plugin should implement SubscriberInterface. */ final protected function registerListener(string $methodName) @@ -362,7 +362,7 @@ final protected function registerListener(string $methodName) * * @since 4.0.0 * - * @deprecated 5.2 will be removed in 7.0 + * @deprecated __DEPLOY_VERSION__ will be removed in 7.0 * Plugin should implement SubscriberInterface. */ private function parameterImplementsEventInterface(\ReflectionParameter $parameter): bool From b81a90a770076b79980e63ede837b3eef0dacfa6 Mon Sep 17 00:00:00 2001 From: Fedik Date: Mon, 10 Mar 2025 17:56:11 +0200 Subject: [PATCH 10/16] tst --- libraries/src/Plugin/CMSPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index 61475104b4f30..33a796760dd11 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -346,7 +346,7 @@ function (AbstractEvent $event) use ($methodName) { * @since 4.0.0 * * @deprecated __DEPLOY_VERSION__ will be removed in 7.0 - * Plugin should implement SubscriberInterface. + * Plugin should implement SubscriberInterface.1 */ final protected function registerListener(string $methodName) { From 1ce8a96b0d7b798abc9d85fd2e518237c3fa5d1b Mon Sep 17 00:00:00 2001 From: Fedik Date: Mon, 10 Mar 2025 17:56:16 +0200 Subject: [PATCH 11/16] tst --- libraries/src/Plugin/CMSPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index 33a796760dd11..61475104b4f30 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -346,7 +346,7 @@ function (AbstractEvent $event) use ($methodName) { * @since 4.0.0 * * @deprecated __DEPLOY_VERSION__ will be removed in 7.0 - * Plugin should implement SubscriberInterface.1 + * Plugin should implement SubscriberInterface. */ final protected function registerListener(string $methodName) { From 029459a2766de19db1fd02863316c2995fea7160 Mon Sep 17 00:00:00 2001 From: Fedik Date: Thu, 13 Mar 2025 18:03:36 +0200 Subject: [PATCH 12/16] PluginWithSubscriberInterface --- .../PluginWithSubscriberInterface.php | 28 +++++++++++++++++++ libraries/src/Plugin/PluginHelper.php | 11 ++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 libraries/src/Extension/PluginWithSubscriberInterface.php diff --git a/libraries/src/Extension/PluginWithSubscriberInterface.php b/libraries/src/Extension/PluginWithSubscriberInterface.php new file mode 100644 index 0000000000000..47ad39929f58e --- /dev/null +++ b/libraries/src/Extension/PluginWithSubscriberInterface.php @@ -0,0 +1,28 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\CMS\Extension; + +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + +use Joomla\Event\SubscriberInterface; + +/** + * An interface to help transitioning to SubscriberInterface. + * For plugins which implement this interface method registerListeners() will not be called. + * + * @TODO Remove in 8.0 + * + * @since __DEPLOY_VERSION__ + */ +interface PluginWithSubscriberInterface extends SubscriberInterface +{ +} diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index 65741066e8e8c..a113092d2c62f 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -10,6 +10,7 @@ namespace Joomla\CMS\Plugin; use Joomla\CMS\Cache\Exception\CacheExceptionInterface; +use Joomla\CMS\Extension\PluginWithSubscriberInterface; use Joomla\CMS\Factory; use Joomla\Event\DispatcherAwareInterface; use Joomla\Event\DispatcherInterface; @@ -231,7 +232,7 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa $plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type); - if ($dispatcher && $plugin instanceof DispatcherAwareInterface) { + if ($dispatcher && $plugin instanceof DispatcherAwareInterface && !$plugin instanceof DispatcherAwareInterface) { $plugin->setDispatcher($dispatcher); } @@ -239,8 +240,12 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa return; } - // @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin);, for plugins which implements SubscriberInterface. - $plugin->registerListeners(); + // @TODO: From 7.0 it should use $dispatcher->addSubscriber($plugin) only, and check only for SubscriberInterface. + if ($plugin instanceof PluginWithSubscriberInterface) { + $dispatcher->addSubscriber($plugin); + } else { + $plugin->registerListeners(); + } } /** From 8ae523ab7c7837804eec6202c022363edb5645e6 Mon Sep 17 00:00:00 2001 From: Fedik Date: Thu, 13 Mar 2025 18:05:16 +0200 Subject: [PATCH 13/16] PluginWithSubscriberInterface --- libraries/src/Plugin/PluginHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index a113092d2c62f..7807507106135 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -232,7 +232,7 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa $plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type); - if ($dispatcher && $plugin instanceof DispatcherAwareInterface && !$plugin instanceof DispatcherAwareInterface) { + if ($dispatcher && $plugin instanceof DispatcherAwareInterface && !$plugin instanceof PluginWithSubscriberInterface) { $plugin->setDispatcher($dispatcher); } From e8c139c465d73aff45bfd8ee0c852a3d3b1304f0 Mon Sep 17 00:00:00 2001 From: Fedik Date: Thu, 15 May 2025 12:44:08 +0300 Subject: [PATCH 14/16] Revert "PluginWithSubscriberInterface" This reverts commit 8ae523ab7c7837804eec6202c022363edb5645e6. --- libraries/src/Plugin/PluginHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index 7807507106135..a113092d2c62f 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -232,7 +232,7 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa $plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type); - if ($dispatcher && $plugin instanceof DispatcherAwareInterface && !$plugin instanceof PluginWithSubscriberInterface) { + if ($dispatcher && $plugin instanceof DispatcherAwareInterface && !$plugin instanceof DispatcherAwareInterface) { $plugin->setDispatcher($dispatcher); } From 21e3ddad53810a996824ab54b04d3612fe1af704 Mon Sep 17 00:00:00 2001 From: Fedik Date: Thu, 15 May 2025 12:44:38 +0300 Subject: [PATCH 15/16] Revert "PluginWithSubscriberInterface" This reverts commit 029459a2766de19db1fd02863316c2995fea7160. --- .../PluginWithSubscriberInterface.php | 28 ------------------- libraries/src/Plugin/PluginHelper.php | 11 ++------ 2 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 libraries/src/Extension/PluginWithSubscriberInterface.php diff --git a/libraries/src/Extension/PluginWithSubscriberInterface.php b/libraries/src/Extension/PluginWithSubscriberInterface.php deleted file mode 100644 index 47ad39929f58e..0000000000000 --- a/libraries/src/Extension/PluginWithSubscriberInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace Joomla\CMS\Extension; - -// phpcs:disable PSR1.Files.SideEffects -\defined('_JEXEC') or die; -// phpcs:enable PSR1.Files.SideEffects - -use Joomla\Event\SubscriberInterface; - -/** - * An interface to help transitioning to SubscriberInterface. - * For plugins which implement this interface method registerListeners() will not be called. - * - * @TODO Remove in 8.0 - * - * @since __DEPLOY_VERSION__ - */ -interface PluginWithSubscriberInterface extends SubscriberInterface -{ -} diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index a113092d2c62f..65741066e8e8c 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -10,7 +10,6 @@ namespace Joomla\CMS\Plugin; use Joomla\CMS\Cache\Exception\CacheExceptionInterface; -use Joomla\CMS\Extension\PluginWithSubscriberInterface; use Joomla\CMS\Factory; use Joomla\Event\DispatcherAwareInterface; use Joomla\Event\DispatcherInterface; @@ -232,7 +231,7 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa $plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type); - if ($dispatcher && $plugin instanceof DispatcherAwareInterface && !$plugin instanceof DispatcherAwareInterface) { + if ($dispatcher && $plugin instanceof DispatcherAwareInterface) { $plugin->setDispatcher($dispatcher); } @@ -240,12 +239,8 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa return; } - // @TODO: From 7.0 it should use $dispatcher->addSubscriber($plugin) only, and check only for SubscriberInterface. - if ($plugin instanceof PluginWithSubscriberInterface) { - $dispatcher->addSubscriber($plugin); - } else { - $plugin->registerListeners(); - } + // @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin);, for plugins which implements SubscriberInterface. + $plugin->registerListeners(); } /** From ad154f63ae2764193a735c62e8eba140e9e43a93 Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Sat, 17 May 2025 11:58:58 +0200 Subject: [PATCH 16/16] Update libraries/src/Plugin/PluginHelper.php Co-authored-by: Richard Fath --- libraries/src/Plugin/PluginHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index 65741066e8e8c..08ac384b26d83 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -239,7 +239,7 @@ protected static function import($plugin, $autocreate = true, ?DispatcherInterfa return; } - // @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin);, for plugins which implements SubscriberInterface. + // @TODO: Starting from 7.0 it should use $dispatcher->addSubscriber($plugin); for plugins which implement SubscriberInterface. $plugin->registerListeners(); }