<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bornfree / tactician-doctrine-domain-events example snippets
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));
}
}
use BornFree\TacticianDoctrineDomainEvent\EventListener\CollectsEventsFromEntities;
$eventRecorder = new CollectsEventsFromEntities();
$entityManager->getConnection()->getEventManager()->addEventSubscriber($eventRecorder);
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
]
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.