Daniel ab1334c0cf the whole shebang | 10 年之前 | |
---|---|---|
.. | ||
Debug | 10 年之前 | |
Tests | 10 年之前 | |
.gitignore | 10 年之前 | |
CHANGELOG.md | 10 年之前 | |
ContainerAwareEventDispatcher.php | 10 年之前 | |
Event.php | 10 年之前 | |
EventDispatcher.php | 10 年之前 | |
EventDispatcherInterface.php | 10 年之前 | |
EventSubscriberInterface.php | 10 年之前 | |
GenericEvent.php | 10 年之前 | |
ImmutableEventDispatcher.php | 10 年之前 | |
LICENSE | 10 年之前 | |
README.md | 10 年之前 | |
composer.json | 10 年之前 | |
phpunit.xml.dist | 10 年之前 |
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 --dev
$ phpunit