-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align classes according to prooph/common integration
- Loading branch information
Alexander Miertsch
committed
May 1, 2015
1 parent
3e6c860
commit e83d533
Showing
10 changed files
with
25 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
|
||
|
||
before_script: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,121 +9,42 @@ | |
namespace Prooph\EventSourcing; | ||
|
||
use Assert\Assertion; | ||
use Codeliner\ArrayReader\ArrayReader; | ||
use Rhumsaa\Uuid\Uuid; | ||
use Prooph\Common\Messaging\DomainEvent; | ||
|
||
/** | ||
* AggregateChanged | ||
* | ||
* @author Alexander Miertsch <[email protected]> | ||
* @package Prooph\EventSourcing | ||
*/ | ||
class AggregateChanged implements DomainEvent | ||
class AggregateChanged extends DomainEvent | ||
{ | ||
/** | ||
* @var Uuid | ||
*/ | ||
protected $uuid; | ||
|
||
/** | ||
* @var mixed | ||
* @var string | ||
*/ | ||
protected $aggregateId; | ||
|
||
/** | ||
* This property is injected via Reflection | ||
* | ||
* @var int | ||
*/ | ||
protected $version; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $payload; | ||
|
||
/** | ||
* @var \DateTime | ||
*/ | ||
protected $occurredOn; | ||
|
||
/** | ||
* @var ArrayReader | ||
*/ | ||
private $payloadReader; | ||
|
||
/** | ||
* @param string $aggregateId | ||
* @param array $payload | ||
* @return static | ||
*/ | ||
public static function occur($aggregateId, array $payload) | ||
{ | ||
return new static($aggregateId, $payload); | ||
} | ||
|
||
/** | ||
* @param string $aggregateId | ||
* @param array $payload | ||
* @param Uuid $uuid | ||
* @param \DateTime $occurredOn | ||
* @param $version | ||
* @return static | ||
*/ | ||
public static function reconstitute($aggregateId, array $payload, Uuid $uuid, \DateTime $occurredOn, $version) | ||
{ | ||
return new static($aggregateId, $payload, $uuid, $occurredOn, $version); | ||
} | ||
|
||
/** | ||
* @param string $aggregateId | ||
* @param array $payload | ||
* @param Uuid $uuid | ||
* @param \DateTime $occurredOn | ||
* @param null|int $version | ||
*/ | ||
protected function __construct($aggregateId, array $payload, Uuid $uuid = null, \DateTime $occurredOn = null, $version = null) | ||
{ | ||
if (is_null($uuid)) { | ||
$uuid = Uuid::uuid4(); | ||
} | ||
|
||
if (is_null($occurredOn)) { | ||
$occurredOn = new \DateTime(); | ||
} | ||
$instance = new static(__CLASS__, $payload, 1, null, null, ['aggregate_id' => $aggregateId]); | ||
|
||
$this->setAggregateId($aggregateId); | ||
$this->payload = $payload; | ||
$this->uuid = $uuid; | ||
$this->occurredOn = $occurredOn; | ||
//We reset version here, because the AggregateTranslator will inject the version of the aggregate via method trackVersion | ||
$instance->version = null; | ||
|
||
if (! is_null($version)) { | ||
$this->setVersion($version); | ||
} | ||
return $instance; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function aggregateId() | ||
{ | ||
return $this->aggregateId; | ||
} | ||
|
||
/** | ||
* @return Uuid | ||
*/ | ||
public function uuid() | ||
{ | ||
return $this->uuid; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function version() | ||
{ | ||
return $this->version; | ||
return $this->metadata['aggregate_id']; | ||
} | ||
|
||
/** | ||
|
@@ -155,34 +76,6 @@ protected function setVersion($version) | |
$this->version = $version; | ||
} | ||
|
||
/** | ||
* @return \DateTime | ||
*/ | ||
public function occurredOn() | ||
{ | ||
return $this->occurredOn; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function payload() | ||
{ | ||
return $this->payload; | ||
} | ||
|
||
/** | ||
* @return ArrayReader | ||
*/ | ||
public function toPayloadReader() | ||
{ | ||
if (is_null($this->payloadReader)) { | ||
$this->payloadReader = new ArrayReader($this->payload()); | ||
} | ||
|
||
return $this->payloadReader; | ||
} | ||
|
||
/** | ||
* @param string $aggregateId | ||
*/ | ||
|
@@ -191,6 +84,6 @@ protected function setAggregateId($aggregateId) | |
Assertion::string($aggregateId); | ||
Assertion::notEmpty($aggregateId); | ||
|
||
$this->aggregateId = $aggregateId; | ||
$this->metadata['aggregate_id'] = $aggregateId; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
110 changes: 0 additions & 110 deletions
110
src/Prooph/EventSourcing/EventStoreIntegration/AggregateChangedEventHydrator.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.