mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
Treat duplicate in backend and setup confirm page of merge
This commit is contained in:
@@ -25,43 +25,13 @@ class AccompanyingPeriodWorkMergeService
|
||||
*/
|
||||
public function merge(AccompanyingPeriodWork $toKeep, AccompanyingPeriodWork $toDelete): void
|
||||
{
|
||||
// Transfer non-duplicate data
|
||||
$this->transferData($toKeep, $toDelete);
|
||||
|
||||
// Update linked entities
|
||||
$this->updateReferences($toKeep, $toDelete);
|
||||
|
||||
$this->em->remove($toDelete);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private function transferData(AccompanyingPeriodWork $toKeep, AccompanyingPeriodWork $toDelete): void
|
||||
{
|
||||
$conn = $this->em->getConnection();
|
||||
|
||||
$sqlStatements = [
|
||||
$this->generateStartDateSQL(),
|
||||
$this->generateEndDateSQL(),
|
||||
$this->generateCommentSQL(),
|
||||
];
|
||||
|
||||
$conn->beginTransaction();
|
||||
|
||||
try {
|
||||
foreach ($sqlStatements as $sql) {
|
||||
$conn->executeQuery($sql, ['toDelete' => $toDelete->getId(), 'toKeep' => $toKeep->getId()]);
|
||||
}
|
||||
$conn->commit();
|
||||
} catch (\Exception $e) {
|
||||
$conn->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function generateStartDateSQL(): string
|
||||
/* private function generateStartDateSQL(): string
|
||||
{
|
||||
return '
|
||||
UPDATE chill_person_accompanying_period_work
|
||||
@@ -99,7 +69,7 @@ class AccompanyingPeriodWorkMergeService
|
||||
NULLIF(TRIM((SELECT note FROM chill_person_accompanying_period_work WHERE id = :toDelete)), '')
|
||||
)
|
||||
WHERE id = :toKeep";
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
|
Reference in New Issue
Block a user