bentools/stoppable-event-trait

PSR-14 Stoppable Event implementation, shipped as a trait.

1.0 2023-01-13 16:40 UTC

This package is auto-updated.

Last update: 2024-12-13 20:49:49 UTC


README

Latest Version on Packagist Total Downloads Tests Coverage

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.