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 snapshotter generic and add adapter for aggregate root #73

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

make snapshotter generic and add adapter for aggregate root #73

alanbem opened this issue Jul 20, 2019 · 0 comments

Comments

@alanbem
Copy link
Member

alanbem commented Jul 20, 2019

e.g.

namespace Entity;

interface Snapshotter
{
    public function restoreToSnapshot(Entity $entity) : ?Entity;

    public function takeSnapshot(Entity $entity) : void;
}

and

namespace Entity\AggregateRoot;

interface Snapshotter
{
    public function restoreToSnapshot(AggregateRoot $aggregate) : ?AggregateRoot;

    public function takeSnapshot(AggregateRoot $aggregate) : void;
}

class EntitySnapshotterAdapter implements AggregateRoot\Snapshotter
{
    private $snapshotter;
   
    public function __construct(Entity\Snapshotter $snasphotter)
    {
        $this->snapshotter = $snapshotter;
    }
   
    public function restoreToSnapshot(AggregateRoot $aggregate) : ?AggregateRoot
    { 
        return $this->snapshotter->restoreToSnapshot($aggregate);
    }

    public function takeSnapshot(AggregateRoot $aggregate) : void
    {
        $this->snapshotter->takeSnapshot($aggregate);
    }
}

Just an idea - needs some refinement.

@alanbem alanbem changed the title make snapshotter generic... make snapshotter generic and add adapter for aggregate root Jul 20, 2019
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