Symfony2 Bundle for league/event
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitattributes
.gitignore
.scrutinizer.yml
.travis.yml
CHANGELOG.md
README.md
composer.json
phpunit.xml.dist

README.md

League Event Bundle for Symfony2

Installation

composer require frankdejonge/league-event-bundle

Register the bundle:

$bundles = array(
    ...
    new FrankDeJonge\LeagueEventBundle\LeagueEventBundle(),
    ...
);

Usage

By default an emitter is registered under the league_event.emitter id.

$emitter = $container->get('league_event.emitter');

Event listeners can be added to the emitter by tagging it with league_event.emitter.

---
services:
    my_listener:
        class: Some\Listener
        tags:
            - name: league_event.listener
              event: event.name

Advanced usage

Register custom emitters with custom listener bindings:

---
services:
    my_emitter:
        class: League\Event\Emitter
        tags:
            - name: league_event.emitter
              listener_tag: my_emitter.listener
    my_listener:
        class: My\Awesome\Listener
        tags:
            - name: my_emitter.listener
              event: My\Awesome\DomainEvent

Setting priorities is also possible:

---
services:
    my_listener:
        class: My\Awesome\Listener
        tags:
            - name: league_event.listener
              event: My\Awesome\DomainEvent
              priority: 9001