]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
1 | EventDispatcher Component |
2 | ========================= | |
3 | ||
4 | EventDispatcher implements a lightweight version of the Observer design | |
5 | pattern. | |
6 | ||
7 | use Symfony\Component\EventDispatcher\EventDispatcher; | |
8 | use Symfony\Component\EventDispatcher\Event; | |
9 | ||
10 | $dispatcher = new EventDispatcher(); | |
11 | ||
12 | $dispatcher->addListener('event_name', function (Event $event) { | |
13 | // ... | |
14 | }); | |
15 | ||
16 | $dispatcher->dispatch('event_name'); | |
17 | ||
18 | Resources | |
19 | --------- | |
20 | ||
21 | You can run the unit tests with the following command: | |
22 | ||
23 | $ cd path/to/Symfony/Component/EventDispatcher/ | |
24 | $ composer.phar install --dev | |
25 | $ phpunit |