/** * @param BookAdded $event */ public function onBookAdded(BookAdded $event) { $authors = array_map(function (AuthorAdded $author) { return new Author($author->getFirstName(), $author->getLastName()); }, $event->getAuthors()); $this->storage->upsert($event->getId()->getValue(), new Book($event->getId(), new Authors($authors), $event->getTitle(), $event->getISBN(), true, $event->getVersion())); }
/** * @param BookAdded $event */ protected function applyBookAdded(BookAdded $event) { $this->id = $event->getId(); }