/**
* @param object $eventSourcedAggregateRoot
* @throws Exception\AggregateTypeException
*/
public function addAggregateRoot($eventSourcedAggregateRoot)
{
if (!is_object($eventSourcedAggregateRoot)) {
throw new AggregateTypeException(sprintf('Invalid aggregate given. Aggregates need to be of type object but type of %s given', gettype($eventSourcedAggregateRoot)));
}
$aggregateId = $this->aggregateTranslator->extractAggregateId($eventSourcedAggregateRoot);
$domainEvents = $this->aggregateTranslator->extractPendingStreamEvents($eventSourcedAggregateRoot);
$this->streamStrategy->addEventsForNewAggregateRoot($this->aggregateType, $aggregateId, $domainEvents, $eventSourcedAggregateRoot);
$this->identityMap[$aggregateId] = $eventSourcedAggregateRoot;
}