Commit fd5ceac2 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Opérations de synchro mises dans une transaction

parent fdaffa54
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
<?php


namespace UnicaenDbImport\Service;

use Exception;
use UnicaenApp\Exception\RuntimeException;
use UnicaenDbImport\Config\Config;
use UnicaenDbImport\Domain\Exception\NotFoundException;
use UnicaenDbImport\Domain\ImportInterface;
@@ -90,6 +90,7 @@ class SynchroService
    {
        $source = $synchro->getSource();
        $destination = $synchro->getDestination();
        $connection = $destination->getConnection();

        $result = new SynchroResult();
        $result->setSynchro($synchro);
@@ -106,7 +107,15 @@ class SynchroService
            $this->facadeService->validateDestination();
            $this->facadeService->validateSource();
            $this->facadeService->discoverSourceColumns();

            $connection->beginTransaction();
            try {
                $diffViewRequestResult = $this->facadeService->synchronizeDestination();
                $connection->commit();
            } catch (Exception $e) {
                $connection->rollBack();
                throw new RuntimeException("Erreur rencontrée. Rollback effectué.", null, $e);
            }

            $result->setDiffViewRequestResult($diffViewRequestResult);