2017-25 © Pedro Peláez
 

library tactician-doctrine-domain-events

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

image

bornfree/tactician-doctrine-domain-events

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  • Saturday, November 25, 2017
  • by borN_free
  • Repository
  • 3 Watchers
  • 5 Stars
  • 16,178 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 39 % Grown

The README.md

Tactician Domain Events - Doctrine Bridge

Build Status codecov Scrutinizer Code Quality Latest Stable Version, (*1)

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM, (*2)

Installation

Install via composer, (*3)

composer require bornfree/tactician-doctrine-domain-events

Usage

Using the events recorder facilities you can let Doctrine ORM collect domain events and subsequently let the EventDispatcher handle them., (*4)

Make sure that your entities implement the ContainsRecordedMessages interface. Use the EventRecorderCapabilities trait from Tactician Domain Events library to conveniently record events from inside the entity:, (*5)

use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;
use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;

class Task implements ContainsRecordedMessages
{
    use EventRecorderCapabilities;

    public function __construct($name)
    {
        $this->record(new TaskWasCreated($name));
    }
}

Then set up the event recorder for Doctrine entities:, (*6)

use BornFree\TacticianDoctrineDomainEvent\EventListener\CollectsEventsFromEntities;

$eventRecorder = new CollectsEventsFromEntities();

$entityManager->getConnection()->getEventManager()->addEventSubscriber($eventRecorder);
Syfmony integration

This listener will be registered automatically with Symfony, see the documentation, (*7)

The event recorder will loop over all the entities that were involved in the last database transaction and collect their internally recorded events., (*8)

After a database transaction was completed successfully these events should be handled by the EventDispatcher. This is done by a specialized middleware, which should be added to the command bus before the middleware that is responsible for handling the transaction., (*9)

use League\Tactician\CommandBus;
use League\Tactician\Doctrine\ORM\TransactionMiddleware;
use namespace BornFree\TacticianDomainEvent\Middleware\ReleaseRecordedEventsMiddleware;

// see the previous sections about $eventRecorder and $eventDispatcher
$releaseRecordedEventsMiddleware = new ReleaseRecordedEventsMiddleware($eventRecorder, $eventDispatcher);

$commandBus = new CommandBus(
    [
        $releaseRecordedEventsMiddleware, // it should be before transaction middleware
        $transactionMiddleware,
        $commandHandlerMiddleware
    ]
);

License

Copyright (c) 2017, Maks Rafalko, (*10)

Under MIT license, read LICENSE file., (*11)

The Versions

25/11 2017

dev-master

9999999-dev

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

19/11 2017

0.4.0

0.4.0.0

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

25/02 2017

0.3.3

0.3.3.0

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

04/02 2017

0.3.2

0.3.2.0

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2017

0.3.1

0.3.1.0

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2017

0.3.0

0.3.0.0

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

27/01 2017

0.2.0

0.2.0.0

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

22/01 2017

0.1.1

0.1.1.0

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires

22/01 2017

0.1

0.1.0.0

The bridge to provide Domain Events handling with Tactician command bus and Doctrine ORM

  Sources   Download

MIT

The Requires

 

The Development Requires