From 9fe55e8bff00dcc0ca69911bbba243a2d46aca59 Mon Sep 17 00:00:00 2001 From: Fedik Date: Sat, 15 Jun 2024 15:14:48 +0300 Subject: [PATCH 1/5] Info about new Subscriber Registration Checker --- ...menting-subscriber-registration-checker.md | 31 +++++++++++++++++++ migrations/51-52/new-features.md | 8 +++++ 2 files changed, 39 insertions(+) create mode 100644 docs/building-extensions/plugins/implementing-subscriber-registration-checker.md diff --git a/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md b/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md new file mode 100644 index 00000000..f0d0ea30 --- /dev/null +++ b/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md @@ -0,0 +1,31 @@ +Subscriber Registration Checker +================================ + +Subscriber Registration Checker `Joomla\CMS\Event\SubscriberRegistrationCheckerInterface` interface allows the Plugin to be checked before listener registration. +This allows the plugin to be registered only when special conditions are meet, eg: only for specific application. + +### Example: + +Creating the plugin that will be run only for Administrator or Api application: + +```php +use Joomla\CMS\Event\SubscriberRegistrationCheckerInterface; +use Joomla\CMS\Plugin\CMSPlugin; + +new MyExamplePlugin extends CMSPlugin implements SubscriberRegistrationCheckerInterface +{ + //... rest of the plugin code + + /** + * Check whether the Subscriber (or event listener) should be registered. + * + * @return bool + */ + public function shouldRegisterListeners(): bool + { + $app = $this->getApplication(); + + return $app->isClient('administrator') || $app->isClient('api'); + } +} +``` diff --git a/migrations/51-52/new-features.md b/migrations/51-52/new-features.md index 246c7074..0bf0185a 100644 --- a/migrations/51-52/new-features.md +++ b/migrations/51-52/new-features.md @@ -16,3 +16,11 @@ This new feature adds a "total" counter at the bottom near the pagination in Joo displaying the number of items available after applying filters for easier item management. PR: [43575](https://github.com/joomla/joomla-cms/pull/43575) + + +#### New interface for Plugins `SubscriberRegistrationCheckerInterface` + +Adding interface that allows the Plugin to be checked before listener registration. +PR: https://github.com/joomla/joomla-cms/pull/43657 + +More details here [Subscriber Registration Checker](/docs/building-extensions/plugins/implementing-subscriber-registration-checker). From e9f250d70675c211541011652b24ddc556fb45a7 Mon Sep 17 00:00:00 2001 From: Fedik Date: Sat, 15 Jun 2024 15:18:20 +0300 Subject: [PATCH 2/5] Info about new Subscriber Registration Checker --- .../plugins/implementing-subscriber-registration-checker.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md b/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md index f0d0ea30..98277151 100644 --- a/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md +++ b/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md @@ -2,7 +2,7 @@ Subscriber Registration Checker ================================ Subscriber Registration Checker `Joomla\CMS\Event\SubscriberRegistrationCheckerInterface` interface allows the Plugin to be checked before listener registration. -This allows the plugin to be registered only when special conditions are meet, eg: only for specific application. +This allows the plugin to be registered only when special conditions are met, e.g., only for specific applications. ### Example: @@ -12,7 +12,7 @@ Creating the plugin that will be run only for Administrator or Api application: use Joomla\CMS\Event\SubscriberRegistrationCheckerInterface; use Joomla\CMS\Plugin\CMSPlugin; -new MyExamplePlugin extends CMSPlugin implements SubscriberRegistrationCheckerInterface +class MyExamplePlugin extends CMSPlugin implements SubscriberRegistrationCheckerInterface { //... rest of the plugin code From 11b14a0185d7a8a5e3c6cee970a8dd3b922e049f Mon Sep 17 00:00:00 2001 From: Fedik Date: Sat, 15 Jun 2024 15:24:51 +0300 Subject: [PATCH 3/5] Info about new Subscriber Registration Checker --- migrations/51-52/new-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/51-52/new-features.md b/migrations/51-52/new-features.md index 0bf0185a..a0634382 100644 --- a/migrations/51-52/new-features.md +++ b/migrations/51-52/new-features.md @@ -23,4 +23,4 @@ PR: [43575](https://github.com/joomla/joomla-cms/pull/43575) Adding interface that allows the Plugin to be checked before listener registration. PR: https://github.com/joomla/joomla-cms/pull/43657 -More details here [Subscriber Registration Checker](/docs/building-extensions/plugins/implementing-subscriber-registration-checker). +More details here [Subscriber Registration Checker](https://manual.joomla.org/docs/building-extensions/plugins/implementing-subscriber-registration-checker). From d2515e677af657b84d849b85d818cb5366d8066d Mon Sep 17 00:00:00 2001 From: Fedik Date: Sat, 15 Jun 2024 15:29:27 +0300 Subject: [PATCH 4/5] Info about new Subscriber Registration Checker --- ...-registration-checker.md => advanced-plugin-features.md} | 6 ++++-- migrations/51-52/new-features.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) rename docs/building-extensions/plugins/{implementing-subscriber-registration-checker.md => advanced-plugin-features.md} (91%) diff --git a/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md b/docs/building-extensions/plugins/advanced-plugin-features.md similarity index 91% rename from docs/building-extensions/plugins/implementing-subscriber-registration-checker.md rename to docs/building-extensions/plugins/advanced-plugin-features.md index 98277151..401a0035 100644 --- a/docs/building-extensions/plugins/implementing-subscriber-registration-checker.md +++ b/docs/building-extensions/plugins/advanced-plugin-features.md @@ -1,5 +1,7 @@ -Subscriber Registration Checker -================================ +Advanced plugin features +======================== + +## Subscriber Registration Checker Subscriber Registration Checker `Joomla\CMS\Event\SubscriberRegistrationCheckerInterface` interface allows the Plugin to be checked before listener registration. This allows the plugin to be registered only when special conditions are met, e.g., only for specific applications. diff --git a/migrations/51-52/new-features.md b/migrations/51-52/new-features.md index a0634382..b598c30b 100644 --- a/migrations/51-52/new-features.md +++ b/migrations/51-52/new-features.md @@ -23,4 +23,4 @@ PR: [43575](https://github.com/joomla/joomla-cms/pull/43575) Adding interface that allows the Plugin to be checked before listener registration. PR: https://github.com/joomla/joomla-cms/pull/43657 -More details here [Subscriber Registration Checker](https://manual.joomla.org/docs/building-extensions/plugins/implementing-subscriber-registration-checker). +More details here [Subscriber Registration Checker](https://manual.joomla.org/docs/building-extensions/plugins/advanced-plugin-features#subscriber-registration-checker). From 5ad31a32f057b17eddf89348c8c0a44b588a241f Mon Sep 17 00:00:00 2001 From: Fedik Date: Sat, 15 Jun 2024 15:29:51 +0300 Subject: [PATCH 5/5] Info about new Subscriber Registration Checker --- docs/building-extensions/plugins/advanced-plugin-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/building-extensions/plugins/advanced-plugin-features.md b/docs/building-extensions/plugins/advanced-plugin-features.md index 401a0035..f8d116e1 100644 --- a/docs/building-extensions/plugins/advanced-plugin-features.md +++ b/docs/building-extensions/plugins/advanced-plugin-features.md @@ -1,4 +1,4 @@ -Advanced plugin features +Advanced Plugin features ======================== ## Subscriber Registration Checker