bentools / stoppable-event-trait
PSR-14 Stoppable Event implementation, shipped as a trait.
Fund package maintenance!
bpolaszek
Requires
- php: >=7.2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- pestphp/pest: ^1.20
- psr/event-dispatcher: ^1.0
- spatie/ray: ^1.28
- symfony/event-dispatcher: ^5.0|^6.0
README
This is just a trait implementation of PSR-14's StoppableEventInterface
.
Usage
use Bentools\StoppableEventTrait\StoppableEventTrait; use Psr\EventDispatcher\StoppableEventInterface; final class StoppableEvent implements StoppableEventInterface { use StoppableEventTrait; }
Any listener can call $event->stopPropagation()
on your event, preventing further propagation of the event,
regardless of the PSR-14 implementation you're using (as soon as they properly handle StoppableEventInterface
events)
Installation
You can install the package via composer:
composer require bentools/stoppable-event-trait
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.