2a673d8626
The ContainerAwareTraceableEventDispatcher class was tied to both the Symfony container and the HttpKernel profiler. It made it non reusable in another context. The new TraceableEventDispatcher only keeps the HttpKernel profiler integration and is able to wrap any other event dispatcher. It makes it reusable in frameworks using the Symfony HttpKernel component like Silex. The only drawback is that we don't have access to the listener priorities in the collected data anymore (but the listeners are still ordered correctly). The change is still worth it I think. |
||
---|---|---|
.. | ||
Debug | ||
Tests | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
ContainerAwareEventDispatcher.php | ||
Event.php | ||
EventDispatcher.php | ||
EventDispatcherInterface.php | ||
EventSubscriberInterface.php | ||
GenericEvent.php | ||
ImmutableEventDispatcher.php | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md |
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
If you also want to run the unit tests that depend on other Symfony Components, install dev dependencies before running PHPUnit:
php composer.phar install --dev