|
|
@@ -608,14 +608,15 @@ class OrganizationFactory
|
|
|
|
|
|
$withError = false;
|
|
|
|
|
|
- $personsIds = [];
|
|
|
-
|
|
|
try {
|
|
|
-// $this->deleteOrganizationAccesses($organization);
|
|
|
+ // On doit gérer à part la suppression des Access afin de supprimer au passage les Person devenues 'orphelines'
|
|
|
+ $this->deleteOrganizationAccesses($organization);
|
|
|
|
|
|
- // TODO: voir si nécessaire :
|
|
|
-// $this->deleteParameters($organization);
|
|
|
+ // On est obligé de supprimer manuellement les paramètres, car c'est l'entité Parameters qui est
|
|
|
+ // propriétaire de la relation Organization <=> Parameters
|
|
|
+ $this->entityManager->remove($organization->getParameters());
|
|
|
|
|
|
+ // Toutes les autres entités liées seront supprimées en cascade
|
|
|
$this->entityManager->remove($organization);
|
|
|
|
|
|
$this->entityManager->flush();
|
|
|
@@ -645,7 +646,7 @@ class OrganizationFactory
|
|
|
try {
|
|
|
$this->deleteLocalDirectories($organization);
|
|
|
} catch (\Exception $e) {
|
|
|
- $this->logger->critical("An error happened while deleting the Dolibarr society, please proceed manually.");
|
|
|
+ $this->logger->critical("An error happened while deleting the local directories, please proceed manually.");
|
|
|
$this->logger->debug($e);
|
|
|
$withError = true;
|
|
|
}
|
|
|
@@ -653,7 +654,7 @@ class OrganizationFactory
|
|
|
try {
|
|
|
$this->deleteDirectoriesV1($organization);
|
|
|
} catch (\Exception $e) {
|
|
|
- $this->logger->critical("An error happened while deleting the Dolibarr society, please proceed manually.");
|
|
|
+ $this->logger->critical("An error happened while deleting the V1 directories, please proceed manually.");
|
|
|
$this->logger->debug($e);
|
|
|
$withError = true;
|
|
|
}
|
|
|
@@ -661,16 +662,16 @@ class OrganizationFactory
|
|
|
try {
|
|
|
$this->deleteDirectories59($organization);
|
|
|
} catch (\Exception $e) {
|
|
|
- $this->logger->critical("An error happened while deleting the Dolibarr society, please proceed manually.");
|
|
|
+ $this->logger->critical("An error happened while deleting the 5.9 directories, please proceed manually.");
|
|
|
$this->logger->debug($e);
|
|
|
$withError = true;
|
|
|
}
|
|
|
|
|
|
if ($withError) {
|
|
|
- $organizationCreationRequest->setStatus(OrganizationDeletionRequest::STATUS_OK_WITH_ERRORS);
|
|
|
+ $organizationDeletionRequest->setStatus(OrganizationDeletionRequest::STATUS_OK_WITH_ERRORS);
|
|
|
$this->logger->warning("-- Operation ended with errors, check the logs for more information --");
|
|
|
} else {
|
|
|
- $organizationCreationRequest->setStatus(OrganizationDeletionRequest::STATUS_OK);
|
|
|
+ $organizationDeletionRequest->setStatus(OrganizationDeletionRequest::STATUS_OK);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -692,10 +693,6 @@ class OrganizationFactory
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- protected function deleteParameters(Organization $organization): void {
|
|
|
- $this->entityManager->remove($organization->getParameters());
|
|
|
- }
|
|
|
-
|
|
|
// TODO: à revoir, c'est du many to many
|
|
|
// protected function removeTypeOfPractices(Organization $organization): void {
|
|
|
// foreach ($organization->getTypeOfPractices() as $typeOfPractice) {
|