|
|
12 years ago | |
|---|---|---|
| .. | ||
| Debug | 12 years ago | |
| Tests | 12 years ago | |
| .gitignore | 12 years ago | |
| CHANGELOG.md | 12 years ago | |
| ContainerAwareEventDispatcher.php | 12 years ago | |
| Event.php | 12 years ago | |
| EventDispatcher.php | 12 years ago | |
| EventDispatcherInterface.php | 12 years ago | |
| EventSubscriberInterface.php | 12 years ago | |
| GenericEvent.php | 12 years ago | |
| ImmutableEventDispatcher.php | 12 years ago | |
| LICENSE | 12 years ago | |
| README.md | 12 years ago | |
| composer.json | 12 years ago | |
| phpunit.xml.dist | 12 years ago | |
EventDispatcher implements a lightweight version of the Observer design pattern.
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
$dispatcher = new EventDispatcher();
$dispatcher->addListener('event_name', function (Event $event) {
// ...
});
$dispatcher->dispatch('event_name');
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/EventDispatcher/
$ composer.phar install
$ phpunit