/**
  * {@inheritdoc}
  */
 public function commit(SagaInterface $saga)
 {
     if (!$saga->isActive()) {
         unset($this->managedSagas[$saga->getSagaIdentifier()]);
     } else {
         $this->managedSagas[$saga->getSagaIdentifier()] = $saga;
     }
     $saga->getAssociationValues()->commit();
 }
 public function commit(SagaInterface $saga)
 {
     if (!$saga->isActive()) {
         $this->deleteSaga($saga);
     } else {
         $sagaType = $this->typeOf($saga);
         $associationValues = $saga->getAssociationValues();
         foreach ($associationValues->addedAssociations() as $av) {
             $this->storeAssociationValue($av, $sagaType, $saga->getSagaIdentifier());
         }
         foreach ($associationValues->removedAssociations() as $av) {
             $this->removeAssociationValue($av, $sagaType, $saga->getSagaIdentifier());
         }
         $associationValues->commit();
         $this->updateSaga($saga);
     }
 }