This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/EventDispatcher
Fabien Potencier 673bbb8a8e fixed CS
2012-03-11 18:00:25 +01:00
..
composer.json Removed version field 2012-02-27 09:59:20 +01:00
Event.php fixed CS 2011-12-18 14:36:25 +01:00
EventDispatcher.php [EventDispatcher] Add fluid interface on dispatch() 2012-03-10 09:55:57 +05:45
EventDispatcherInterface.php fixed CS 2012-03-11 18:00:25 +01:00
EventSubscriberInterface.php merged 2.0 2011-12-13 16:12:53 +01:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
README.md tweaked the README files 2011-12-18 14:22:28 +01:00

EventDispatcher Component

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');

Resources

Unit tests:

https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/EventDispatcher