streak
streak copied to clipboard
make snapshotter generic and add adapter for aggregate root
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.