Skip to content
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

Info about new Subscriber Registration Checker #272

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/building-extensions/plugins/advanced-plugin-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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.

### 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;

class 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');
}
}
```
8 changes: 8 additions & 0 deletions migrations/51-52/new-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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](https://manual.joomla.org/docs/building-extensions/plugins/advanced-plugin-features#subscriber-registration-checker).