2014-02-18 18:15:12 +01:00
|
|
|
EventDispatcher Component
|
|
|
|
=========================
|
|
|
|
|
2015-01-19 11:11:45 +01:00
|
|
|
The Symfony EventDispatcher component implements the Mediator pattern in a
|
2014-02-18 18:15:12 +01:00
|
|
|
simple and effective way to make your projects truly extensible.
|
|
|
|
|
2015-01-19 11:11:45 +01:00
|
|
|
```php
|
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
|
|
|
use Symfony\Component\EventDispatcher\Event;
|
2014-02-18 18:15:12 +01:00
|
|
|
|
2015-01-19 11:11:45 +01:00
|
|
|
$dispatcher = new EventDispatcher();
|
2014-02-18 18:15:12 +01:00
|
|
|
|
2015-01-19 11:11:45 +01:00
|
|
|
$dispatcher->addListener('event_name', function (Event $event) {
|
|
|
|
// ...
|
|
|
|
});
|
2014-02-18 18:15:12 +01:00
|
|
|
|
2015-01-19 11:11:45 +01:00
|
|
|
$dispatcher->dispatch('event_name');
|
|
|
|
```
|
2014-02-18 18:15:12 +01:00
|
|
|
|
|
|
|
Resources
|
|
|
|
---------
|
|
|
|
|
|
|
|
You can run the unit tests with the following command:
|
|
|
|
|
|
|
|
$ cd path/to/Symfony/Component/EventDispatcher/
|
2015-06-19 18:51:09 +02:00
|
|
|
$ composer install
|
2014-02-18 18:15:12 +01:00
|
|
|
$ phpunit
|