jdr/event-recorder

Record events to be dipatched later

0.0.2 2017-04-05 19:51 UTC

This package is auto-updated.

Last update: 2024-11-12 03:09:20 UTC


README

Latest Version on Packagist Software License Total Downloads

Install

Via Composer

$ composer require jdr/event-recorder

Usage

To start recording domain events, implement the ContainsRecordedEvents interface. Optionally, you can use the EventRecorderCapabilities trait.

<?php
namespace JDR\App\Entity;

use JDR\EventRecorder\ContainsRecordedEvents;
use JDR\EventRecorder\EventRecorderCapabilities;

class Entity implements ContainsRecordedEvents
{
    use EventRecorderCapabilities;

    public function doSomething()
    {
        // ...

        $this->record(new SomethingHappened());
    }
}

$entity = new Entity();
$entity->doSomething();

// ...

$events = $entity->releaseEvents();

This package also contains a public event recorder.

<?php
namespace JDR\App;

use JDR\EventRecorder\EventRecorder;

$recorder = new EventRecorder();
$recorder->record(new SomethingHappened());

// ...

$events = $recorder->releaseEvents();

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ bin/phpspec run

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email dev@johanderuijter.nl instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.