| @@ 37-129 (lines=93) @@ | ||
| 34 | * @author "David Kalosi" <[email protected]> |
|
| 35 | * @license <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> |
|
| 36 | */ |
|
| 37 | class SimpleSerializedDomainEventData implements SerializedDomainEventDataInterface |
|
| 38 | { |
|
| 39 | ||
| 40 | /** |
|
| 41 | * @var string |
|
| 42 | */ |
|
| 43 | private $eventIdentifier; |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @var string |
|
| 47 | */ |
|
| 48 | private $aggregateIdentifier; |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @var integer |
|
| 52 | */ |
|
| 53 | private $scn; |
|
| 54 | ||
| 55 | /** |
|
| 56 | * @var \DateTime |
|
| 57 | */ |
|
| 58 | private $timestamp; |
|
| 59 | ||
| 60 | /** |
|
| 61 | * @var SimpleSerializedObject |
|
| 62 | */ |
|
| 63 | private $serializedPayload; |
|
| 64 | ||
| 65 | /** |
|
| 66 | * @var SimpleSerializedObject |
|
| 67 | */ |
|
| 68 | private $serializedMetaData; |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Initialize an instance using given properties. This constructor assumes the default SerializedType for meta data |
|
| 72 | * (name = 'org.axonframework.domain.MetaData' and revision = <em>null</em>). |
|
| 73 | * <p/> |
|
| 74 | * Note that the given <code>timestamp</code> must be in a format supported by {@link} DateTime#DateTime(Object)}. |
|
| 75 | * |
|
| 76 | * @param string $eventIdentifier The identifier of the event |
|
| 77 | * @param string $aggregateIdentifier The identifier of the aggregate |
|
| 78 | * @param integer $scn The sequence number of the event |
|
| 79 | * @param \DateTime $timestamp The timestamp of the event (format must be supported by {@link |
|
| 80 | * DateTime#DateTime(Object)}) |
|
| 81 | * @param string $payloadType The type identifier of the serialized payload |
|
| 82 | * @param string $payloadRevision The revision of the serialized payload |
|
| 83 | * @param mixed $payload The serialized representation of the event |
|
| 84 | * @param mixed $metaData The serialized representation of the meta data |
|
| 85 | */ |
|
| 86 | public function __construct($eventIdentifier, $aggregateIdentifier, $scn, |
|
| 87 | $timestamp, $payloadType, $payloadRevision, $payload, $metaData) |
|
| 88 | { |
|
| 89 | $this->eventIdentifier = $eventIdentifier; |
|
| 90 | $this->aggregateIdentifier = $aggregateIdentifier; |
|
| 91 | $this->scn = $scn; |
|
| 92 | $this->timestamp = $timestamp; |
|
| 93 | $this->serializedPayload = new SimpleSerializedObject($payload, |
|
| 94 | new SimpleSerializedType($payloadType, $payloadRevision)); |
|
| 95 | $this->serializedMetaData = new SimpleSerializedObject($metaData, |
|
| 96 | new SimpleSerializedType('Governor\Framework\Domain\MetaData')); |
|
| 97 | } |
|
| 98 | ||
| 99 | public function getEventIdentifier() |
|
| 100 | { |
|
| 101 | return $this->eventIdentifier; |
|
| 102 | } |
|
| 103 | ||
| 104 | public function getAggregateIdentifier() |
|
| 105 | { |
|
| 106 | return $this->aggregateIdentifier; |
|
| 107 | } |
|
| 108 | ||
| 109 | public function getScn() |
|
| 110 | { |
|
| 111 | return $this->scn; |
|
| 112 | } |
|
| 113 | ||
| 114 | public function getTimestamp() |
|
| 115 | { |
|
| 116 | return $this->timestamp; |
|
| 117 | } |
|
| 118 | ||
| 119 | public function getMetaData() |
|
| 120 | { |
|
| 121 | return $this->serializedMetaData; |
|
| 122 | } |
|
| 123 | ||
| 124 | public function getPayload() |
|
| 125 | { |
|
| 126 | return $this->serializedPayload; |
|
| 127 | } |
|
| 128 | ||
| 129 | } |
|
| 130 | ||
| @@ 18-134 (lines=117) @@ | ||
| 15 | * |
|
| 16 | * @author david |
|
| 17 | */ |
|
| 18 | class SimpleSerializedDomainEventData implements SerializedDomainEventDataInterface |
|
| 19 | { |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var string |
|
| 23 | */ |
|
| 24 | private $eventIdentifier; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @var string |
|
| 28 | */ |
|
| 29 | private $aggregateIdentifier; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @var integer |
|
| 33 | */ |
|
| 34 | private $scn; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @var \DateTime |
|
| 38 | */ |
|
| 39 | private $timestamp; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @var SerializedObjectInterface |
|
| 43 | */ |
|
| 44 | private $serializedPayload; |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @var SerializedObjectInterface |
|
| 48 | */ |
|
| 49 | private $serializedMetaData; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @param string $eventIdentifier |
|
| 53 | * @param string $aggregateIdentifier |
|
| 54 | * @param int $scn |
|
| 55 | * @param \DateTime $timestamp |
|
| 56 | * @param string $payloadType |
|
| 57 | * @param string $payloadRevision |
|
| 58 | * @param string $payload |
|
| 59 | * @param string $metaData |
|
| 60 | */ |
|
| 61 | public function __construct( |
|
| 62 | $eventIdentifier, |
|
| 63 | $aggregateIdentifier, |
|
| 64 | $scn, |
|
| 65 | \DateTime $timestamp, |
|
| 66 | $payloadType, |
|
| 67 | $payloadRevision, |
|
| 68 | $payload, |
|
| 69 | $metaData |
|
| 70 | ) { |
|
| 71 | $this->eventIdentifier = $eventIdentifier; |
|
| 72 | $this->aggregateIdentifier = $aggregateIdentifier; |
|
| 73 | $this->scn = $scn; |
|
| 74 | $this->timestamp = $timestamp; |
|
| 75 | $this->serializedPayload = new SimpleSerializedObject( |
|
| 76 | $payload, |
|
| 77 | new SimpleSerializedType($payloadType, $payloadRevision) |
|
| 78 | ); |
|
| 79 | $this->serializedMetaData = new SimpleSerializedObject( |
|
| 80 | $metaData, |
|
| 81 | new SimpleSerializedType(MetaData::class) |
|
| 82 | ); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * @return string |
|
| 87 | */ |
|
| 88 | public function getAggregateIdentifier() |
|
| 89 | { |
|
| 90 | return $this->aggregateIdentifier; |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * @return string |
|
| 95 | */ |
|
| 96 | public function getEventIdentifier() |
|
| 97 | { |
|
| 98 | return $this->eventIdentifier; |
|
| 99 | } |
|
| 100 | ||
| 101 | /** |
|
| 102 | * @return SerializedObjectInterface |
|
| 103 | */ |
|
| 104 | public function getMetaData() |
|
| 105 | { |
|
| 106 | return $this->serializedMetaData; |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * @return SerializedObjectInterface |
|
| 111 | */ |
|
| 112 | public function getPayload() |
|
| 113 | { |
|
| 114 | return $this->serializedPayload; |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * @return int |
|
| 119 | */ |
|
| 120 | public function getScn() |
|
| 121 | { |
|
| 122 | return $this->scn; |
|
| 123 | } |
|
| 124 | ||
| 125 | /** |
|
| 126 | * |
|
| 127 | * @return \DateTime |
|
| 128 | */ |
|
| 129 | public function getTimestamp() |
|
| 130 | { |
|
| 131 | return $this->timestamp; |
|
| 132 | } |
|
| 133 | ||
| 134 | } |
|
| 135 | ||