Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions will be thrown if aggregate has no pending events #42

Closed
oqq opened this issue Dec 23, 2016 · 4 comments
Closed

Exceptions will be thrown if aggregate has no pending events #42

oqq opened this issue Dec 23, 2016 · 4 comments
Labels

Comments

@oqq
Copy link
Member

oqq commented Dec 23, 2016

Tested with 5.0.0-beta1 Release

If I try to save a a aggregate root not having pending events with AggregateRepository::saveAggregateRoot, an exception is thrown by method AggregateRepository::isFirstEvent, since this method requires a Message object as first argument.

$firstEvent would be null if there is no pending event in $domainEvents.

$firstEvent = $domainEvents[0];

if ($this->isFirstEvent($firstEvent) && $this->oneStreamPerAggregate) {
    $createStream = true;
}

I would prefer to throw a NoPendingEventsException, or not to do anything If there is no pending event.

Maybe an additional unit test is required for that use case.

@prolic prolic added the bug label Dec 23, 2016
@prolic
Copy link
Member

prolic commented Dec 23, 2016

wanna submit a PR?

@prolic
Copy link
Member

prolic commented Dec 23, 2016

btw: I would prefer no exception, just return early.

like:

if (empty($domainEvents)) {
    return;
}

@prolic
Copy link
Member

prolic commented Jan 3, 2017

@oqq still wanna provide a PR? otherwise I take over when I got time.

@oqq
Copy link
Member Author

oqq commented Jan 3, 2017

i am almost done.. only need to pull it. would be done today or tomorrow.

oqq added a commit to oqq/event-sourcing that referenced this issue Jan 4, 2017
@prolic prolic closed this as completed Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants