https://github.com/bpolaszek/stoppable-event-trait
PSR-14 Stoppable Event implementation, shipped as a trait.
https://github.com/bpolaszek/stoppable-event-trait
Last synced: 11 months ago
JSON representation
PSR-14 Stoppable Event implementation, shipped as a trait.
- Host: GitHub
- URL: https://github.com/bpolaszek/stoppable-event-trait
- Owner: bpolaszek
- License: mit
- Created: 2023-01-13T16:36:37.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-13T16:41:55.000Z (about 3 years ago)
- Last Synced: 2025-01-10T09:59:53.598Z (about 1 year ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# PSR-14 Stoppable Event implementation, shipped as a trait.
[](https://packagist.org/packages/bentools/stoppable-event-trait)
[](https://packagist.org/packages/bentools/stoppable-event-trait)
[](https://github.com/bpolaszek/stoppable-event-trait/actions/workflows/run-tests.yml)
[](https://codecov.io/gh/bpolaszek/stoppable-event-trait)
This is just a trait implementation of PSR-14's `StoppableEventInterface`.
## Usage
```php
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:
```bash
composer require bentools/stoppable-event-trait
```
## Testing
```bash
composer test
```
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.