|
|
@@ -592,7 +592,7 @@ class OrganizationFactory
|
|
|
/**
|
|
|
* /!\ Danger zone /!\
|
|
|
*
|
|
|
- * @param Organization $organization
|
|
|
+ * @param OrganizationDeletionRequest $organizationDeletionRequest
|
|
|
* @return void
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@@ -606,11 +606,15 @@ class OrganizationFactory
|
|
|
|
|
|
$this->entityManager->beginTransaction();
|
|
|
|
|
|
+ $withError = false;
|
|
|
+
|
|
|
+ $personsIds = [];
|
|
|
+
|
|
|
try {
|
|
|
- $this->deleteOrganizationAccesses($organization);
|
|
|
- $this->deleteNetworkOrganizationsChildren($organization);
|
|
|
- $this->deleteParameters($organization);
|
|
|
- $this->deleteOrganizationFiles($organization);
|
|
|
+// $this->deleteOrganizationAccesses($organization);
|
|
|
+
|
|
|
+ // TODO: voir si nécessaire :
|
|
|
+// $this->deleteParameters($organization);
|
|
|
|
|
|
$this->entityManager->remove($organization);
|
|
|
|
|
|
@@ -622,11 +626,52 @@ class OrganizationFactory
|
|
|
throw $e;
|
|
|
}
|
|
|
|
|
|
-// $this->deleteTypo3Website($organization);
|
|
|
+ try {
|
|
|
+ $this->deleteTypo3Website($organization);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->logger->critical("An error happened while deleting the Typo3 website, please proceed manually.");
|
|
|
+ $this->logger->debug($e);
|
|
|
+ $withError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $this->deleteDolibarrSociety($organization);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->logger->critical("An error happened while deleting the Dolibarr society, please proceed manually.");
|
|
|
+ $this->logger->debug($e);
|
|
|
+ $withError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $this->deleteLocalDirectories($organization);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->logger->critical("An error happened while deleting the Dolibarr society, please proceed manually.");
|
|
|
+ $this->logger->debug($e);
|
|
|
+ $withError = true;
|
|
|
+ }
|
|
|
|
|
|
-// $this->deleteDolibarrSociety($organization);
|
|
|
+ try {
|
|
|
+ $this->deleteDirectoriesV1($organization);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->logger->critical("An error happened while deleting the Dolibarr society, please proceed manually.");
|
|
|
+ $this->logger->debug($e);
|
|
|
+ $withError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $this->deleteDirectories59($organization);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->logger->critical("An error happened while deleting the Dolibarr society, please proceed manually.");
|
|
|
+ $this->logger->debug($e);
|
|
|
+ $withError = true;
|
|
|
+ }
|
|
|
|
|
|
-// $this->deleteDirectories($organization);
|
|
|
+ if ($withError) {
|
|
|
+ $organizationCreationRequest->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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -641,37 +686,16 @@ class OrganizationFactory
|
|
|
foreach ($organization->getAccesses() as $access) {
|
|
|
$person = $access->getPerson();
|
|
|
if ($person->getAccesses()->count() === 1) {
|
|
|
- $this->deletePerson($person);
|
|
|
+ $this->entityManager->remove($person);
|
|
|
}
|
|
|
$this->entityManager->remove($access);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- protected function deletePerson(Person $person): void {
|
|
|
- foreach ($person->getPersonFiles() as $personFile) {
|
|
|
- $this->entityManager->remove($personFile);
|
|
|
- }
|
|
|
-
|
|
|
- $this->entityManager->remove($person);
|
|
|
- }
|
|
|
-
|
|
|
- protected function deleteNetworkOrganizationsChildren(Organization $organization): void {
|
|
|
- foreach ($organization->getNetworkOrganizationChildren() as $networkOrganization) {
|
|
|
- $this->entityManager->remove($networkOrganization);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
protected function deleteParameters(Organization $organization): void {
|
|
|
$this->entityManager->remove($organization->getParameters());
|
|
|
}
|
|
|
|
|
|
- // TODO: nettoyer les fichiers sur le disque aussi
|
|
|
- protected function deleteOrganizationFiles(Organization $organization): void {
|
|
|
- foreach ($organization->getFiles() as $file) {
|
|
|
- $this->entityManager->remove($file);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// TODO: à revoir, c'est du many to many
|
|
|
// protected function removeTypeOfPractices(Organization $organization): void {
|
|
|
// foreach ($organization->getTypeOfPractices() as $typeOfPractice) {
|
|
|
@@ -696,7 +720,8 @@ class OrganizationFactory
|
|
|
|
|
|
protected function deleteTypo3Website(Organization $organization): void
|
|
|
{
|
|
|
- $this->typo3Service->deleteSite($organization->getId());
|
|
|
+ // TODO: implement
|
|
|
+// $this->typo3Service->deleteSite($organization->getId());
|
|
|
}
|
|
|
|
|
|
protected function deleteDolibarrSociety(Organization $organization): void
|
|
|
@@ -704,12 +729,18 @@ class OrganizationFactory
|
|
|
// TODO: implement
|
|
|
}
|
|
|
|
|
|
- protected function deleteDirectories(Organization $organization): void
|
|
|
+ protected function deleteLocalDirectories(Organization $organization): void
|
|
|
{
|
|
|
// TODO: implement
|
|
|
}
|
|
|
|
|
|
+ protected function deleteDirectoriesV1(Organization $organization): void
|
|
|
+ {
|
|
|
+ // TODO: implement
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ protected function deleteDirectories59(Organization $organization): void
|
|
|
+ {
|
|
|
+ // TODO: implement
|
|
|
+ }
|
|
|
}
|