public function find(ReturnNumber $returnNumber) { return ProductReturn::fromEvents(array_map(function (StoredEvent $storedEvent) { return $storedEvent->getEvent(); }, $this->registry->getRepository(StoredEvent::class)->findByAggregateId($returnNumber->toString()))); }
public function delete(ReturnNumber $returnNumber) { $outstanding = $this->registry->getRepository(OutstandingReturn::class)->find($returnNumber->toString()); $this->registry->getManager()->remove($outstanding); $this->registry->getManager()->flush(); }