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

make snapshotting easier with event sourcing aggregate trait #74

Open
alanbem opened this issue Jul 21, 2019 · 0 comments
Open

make snapshotting easier with event sourcing aggregate trait #74

alanbem opened this issue Jul 21, 2019 · 0 comments

Comments

@alanbem
Copy link
Member

alanbem commented Jul 21, 2019

Now you have to add internal state of event sourcing aggregate trait manually e.g.

    use Streak\Domain\Event\Sourcing;

    public function fromMemento(array $memento)
    {

        $this->accounts = $memento['accounts'];
 
       // event sourced aggregate trait deserialization below
        $this->events = $memento['events'];
        $this->lastEvent = $memento['last_event'];
        $this->replaying = $memento['replaying'];
        $this->lastReplayed = $memento['last_replayed'];
        $this->version = $memento['version'];
    }

    public function toMemento() : array
    {
        $memento = [

            'accounts' => $this->accounts,

            // event sourced aggregate trait serialization below
            'events' => $this->events,
            'last_event' => $this->lastEvent,
            'replaying' => $this->replaying,
            'last_replayed' => $this->lastReplayed,
            'version' => $this->version,
        ];

        return $memento;
    }

find a way to make it easier, more automatic, even transparent to developer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant