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-04-12 16:21:33 +05:45
..
Debug [EventDispatcher] More logical positions for classes. 2012-04-04 22:03:00 +05:45
Tests [EventDispatcher] Fixed edge case not covered by tests that generated E_NOTICES 2012-04-12 16:21:33 +05:45
composer.json moved event dispatcher classes to the EventDispatcher component 2012-04-02 18:28:49 +02:00
ContainerAwareEventDispatcher.php [EventDispatcher] Fixed edge case not covered by tests that generated E_NOTICES 2012-04-12 16:21:33 +05:45
Event.php fixed CS 2011-12-18 14:36:25 +01:00
EventDispatcher.php merged 2.0 2012-04-12 12:30:32 +02:00
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
phpunit.xml.dist [PhpUnit] Fix the path to the boostrap files in the components 2012-03-30 13:49:28 +02:00
README.md moved event dispatcher classes to the EventDispatcher component 2012-04-02 18:28:49 +02: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

You can run the unit tests with the following command:

phpunit -c src/Symfony/Component/EventDispatcher/

If you also want to run the unit tests that depend on other Symfony Components, declare the following environment variables before running PHPUnit:

export SYMFONY_DEPENDENCY_INJECTION=../path/to/DependencyInjection
export SYMFONY_HTTP_KERNEL=../path/to/HttpKernel