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
2012-07-09 14:43:50 +02:00
..
composer.json removed the version attribute in all composer.json files 2012-01-05 14:51:20 +01:00
Event.php [DoctrineBridge] fixed some CS 2011-12-13 10:22:12 +01:00
EventDispatcher.php fixed phpdoc @param alignment 2012-05-15 18:56:32 +02:00
EventDispatcherInterface.php fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
EventSubscriberInterface.php fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02: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