PHP Class Prooph\EventSourcing\AggregateRoot

Author: Alexander Miertsch ([email protected])
Show file Open project: prooph/event-sourcing Class Usage Examples

Protected Properties

Property Type Description
$recordedEvents AggregateChanged[] List of events that are not committed to the EventStore
$version integer Current version

Protected Methods

Method Description
__construct ( ) We do not allow public access to __construct, this way we make sure that an aggregate root can only be constructed by static factories
aggregateId ( ) : string
apply ( AggregateChanged $e ) Apply given event
determineEventHandlerMethodFor ( AggregateChanged $e ) : string Determine event name
popRecordedEvents ( ) : AggregateChanged[] Get pending events and reset stack
reconstituteFromHistory ( Iterator $historyEvents ) : static
recordThat ( AggregateChanged $event ) Record an aggregate changed event
replay ( Iterator $historyEvents ) : void Replay past events

Method Details

__construct() protected method

We do not allow public access to __construct, this way we make sure that an aggregate root can only be constructed by static factories
protected __construct ( )

aggregateId() abstract protected method

abstract protected aggregateId ( ) : string
return string representation of the unique identifier of the aggregate root

apply() protected method

Apply given event
protected apply ( AggregateChanged $e )
$e AggregateChanged

determineEventHandlerMethodFor() protected method

Determine event name
protected determineEventHandlerMethodFor ( AggregateChanged $e ) : string
$e AggregateChanged
return string

popRecordedEvents() protected method

Get pending events and reset stack
protected popRecordedEvents ( ) : AggregateChanged[]
return AggregateChanged[]

reconstituteFromHistory() protected static method

protected static reconstituteFromHistory ( Iterator $historyEvents ) : static
$historyEvents Iterator
return static

recordThat() protected method

Record an aggregate changed event
protected recordThat ( AggregateChanged $event )
$event AggregateChanged

replay() protected method

Replay past events
protected replay ( Iterator $historyEvents ) : void
$historyEvents Iterator
return void

Property Details

$recordedEvents protected property

List of events that are not committed to the EventStore
protected AggregateChanged[],Prooph\EventSourcing $recordedEvents
return AggregateChanged[]

$version protected property

Current version
protected int $version
return integer