/**
  * {@inheritDoc}
  */
 public function save(State $state, $sagaId)
 {
     if ($state->isDone()) {
         unset($this->states[$sagaId][$state->getId()]);
     } else {
         $this->states[$sagaId][$state->getId()] = $state;
     }
 }
 /**
  * {@inheritDoc}
  */
 public function save(State $state, $sagaId)
 {
     $serializedState = $state->serialize();
     $serializedState['_id'] = $serializedState['id'];
     $serializedState['sagaId'] = $sagaId;
     $serializedState['removed'] = $state->isDone();
     $this->collection->save($serializedState);
 }
 public function handleReservationRejected(ReservationRejected $event, State $state)
 {
     // the seat reservation for the given order is has been rejected, reject the order as well
     $command = new RejectOrder($state->get('orderId'));
     $this->commandBus->dispatch($command);
     // the saga ends here
     $state->isDone();
     return $state;
 }