Skip to content

Commit

Permalink
README about dispatcher option for EventListeners
Browse files Browse the repository at this point in the history
  • Loading branch information
a-menshchikov committed Mar 22, 2023
1 parent 4166f58 commit 352837f
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
[OneLogin SAML](https://github.com/onelogin/php-saml) Symfony Bundle.

> This bundle depends on Symfony 6 and newer. <br>
> For older Symfony versions you can use [hslavich/oneloginsaml-bundle](https://github.com/hslavich/OneloginSamlBundle)
> For older Symfony versions you can
> use [hslavich/oneloginsaml-bundle](https://github.com/hslavich/OneloginSamlBundle)
> which this bundle based on.
## Installation
Expand All @@ -42,7 +43,8 @@ To configure the bundle you need to add configuration in `config/packages/nbgrp_
You can use any configuration format (yaml, xml, or php), but for convenience in this document will
be used yaml.

> Check https://github.com/onelogin/php-saml#settings for more info about OneLogin PHP SAML settings.
> Check https://github.com/onelogin/php-saml#settings for more info about OneLogin PHP SAML
> settings.
``` yaml
nbgrp_onelogin_saml:
Expand Down Expand Up @@ -382,4 +384,27 @@ and `Nbgrp\OneloginSamlBundle\EventListener\User\UserModifiedListener` that can
need to override the default behavior.

Also, you can make your own listeners for `Nbgrp\OneloginSamlBundle\Event\UserCreatedEvent`
and `Nbgrp\OneloginSamlBundle\Event\UserModifiedEvent` events.
and `Nbgrp\OneloginSamlBundle\Event\UserModifiedEvent` events:

``` php
<?php
namespace App\Security;
use Nbgrp\OneloginSamlBundle\Event\UserCreatedEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener(event: UserCreatedEvent::class, dispatcher: 'security.event_dispatcher.main')]
class UserCreatedListener
{
public function __invoke(UserCreatedEvent $event): void
{
// ...
}
}
```

**Important:** you must specify the `dispatcher` option corresponding the firewall which will
trigger the event (`main` in the example above). Read more
about [Security Events](https://symfony.com/doc/current/security.html#security-events).

0 comments on commit 352837f

Please sign in to comment.