for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Event-Sourcing package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\EventSourcing\Entity;
use Borobudur\Cqrs\Message\DomainEventInterface;
/**
* @author Iqbal Maulana <[email protected]>
* @created 8/20/15
trait DomainEventDispatcherTrait
{
use EntityNamingTrait;
* {@inheritdoc}
public function handleRecursively(DomainEventInterface $event)
$this->handle($event);
foreach ($this->getChildEntities() as $entity) {
if ($this instanceof AggregateRootInterface) {
$entity->registerAggregateRoot($this);
} elseif ($this instanceof EntityInterface) {
$entity->registerAggregateRoot($this->{'aggregateRoot'});
}
$entity->handleRecursively($event);
public function handle(DomainEventInterface $event)
$method = $this->getApplyMethodName($event);
if (!method_exists($this, $method)) {
return;
$this->{$method}($event);
* Return child entities.
* Override this method if entity has children.
* @return EntityInterface[]
abstract protected function getChildEntities();