|
|
@@ -98,17 +98,10 @@ class OrganizationFactory
|
|
|
$organization = $this->makeOrganizationWithRelations($organizationCreationRequest);
|
|
|
$this->logger->info("Organization created with all its relations");
|
|
|
|
|
|
- // On persiste et on commit
|
|
|
+ // On persiste et on commit, les objets liés seront persistés en cascade
|
|
|
$this->entityManager->persist($organization);
|
|
|
$this->entityManager->flush();
|
|
|
|
|
|
- // Création de la société Dolibarr
|
|
|
- $dolibarrId = $this->dolibarrApiService->createSociety(
|
|
|
- $organization,
|
|
|
- $organizationCreationRequest->isClient()
|
|
|
- );
|
|
|
- $this->logger->info("New dolibarr structure created (uid : " . $dolibarrId . ")");
|
|
|
-
|
|
|
$this->entityManager->commit();
|
|
|
$this->logger->debug(" - New entities committed in DB");
|
|
|
|
|
|
@@ -120,6 +113,13 @@ class OrganizationFactory
|
|
|
throw $e;
|
|
|
}
|
|
|
|
|
|
+ // Création de la société Dolibarr
|
|
|
+ $dolibarrId = $this->dolibarrApiService->createSociety(
|
|
|
+ $organization,
|
|
|
+ $organizationCreationRequest->isClient()
|
|
|
+ );
|
|
|
+ $this->logger->info("New dolibarr structure created (uid : " . $dolibarrId . ")");
|
|
|
+
|
|
|
// Register the subdomain into the BindFile (takes up to 5min to take effect)
|
|
|
$this->bindFileService->registerSubdomain($organizationCreationRequest->getSubdomain());
|
|
|
$this->logger->info("Subdomain registered");
|
|
|
@@ -243,13 +243,12 @@ class OrganizationFactory
|
|
|
|
|
|
// Création du sous-domaine
|
|
|
$subdomain = $this->makeSubdomain($organizationCreationRequest);
|
|
|
- $subdomain->setOrganization($organization);
|
|
|
+ $organization->addSubdomain($subdomain);
|
|
|
|
|
|
// <--- Pour la rétrocompatibilité avec la v1 ; pourra être supprimé lorsque la migration sera achevée
|
|
|
$parameters = $organization->getParameters();
|
|
|
$parameters->setSubDomain($organizationCreationRequest->getSubdomain());
|
|
|
$parameters->setOtherWebsite('https://' . $organizationCreationRequest->getSubdomain() . '.opentalent.fr');
|
|
|
- $this->entityManager->persist($parameters);
|
|
|
// --->
|
|
|
$this->logger->debug(" - Subdomain created");
|
|
|
|
|
|
@@ -270,9 +269,6 @@ class OrganizationFactory
|
|
|
$organization->setLegalStatus($organizationCreationRequest->getLegalStatus());
|
|
|
$organization->setPrincipalType($organizationCreationRequest->getPrincipalType());
|
|
|
$organization->setIdentifier($organizationCreationRequest->getIdentifier());
|
|
|
-
|
|
|
- $this->entityManager->persist($organization);
|
|
|
-
|
|
|
return $organization;
|
|
|
}
|
|
|
|
|
|
@@ -286,7 +282,6 @@ class OrganizationFactory
|
|
|
protected function makeParameters(OrganizationCreationRequest $organizationCreationRequest): Parameters
|
|
|
{
|
|
|
$parameters = new Parameters();
|
|
|
- $this->entityManager->persist($parameters);
|
|
|
return $parameters;
|
|
|
}
|
|
|
|
|
|
@@ -301,7 +296,6 @@ class OrganizationFactory
|
|
|
{
|
|
|
$settings = new Settings();
|
|
|
$settings->setProduct($organizationCreationRequest->getProduct());
|
|
|
- $this->entityManager->persist($settings);
|
|
|
return $settings;
|
|
|
}
|
|
|
|
|
|
@@ -326,12 +320,10 @@ class OrganizationFactory
|
|
|
$addressPostal->setPostalCode($organizationCreationRequest->getPostalCode());
|
|
|
$addressPostal->setAddressCity($organizationCreationRequest->getCity());
|
|
|
$addressPostal->setAddressCountry($country);
|
|
|
- $this->entityManager->persist($addressPostal);
|
|
|
|
|
|
$organizationAddressPostal = new OrganizationAddressPostal();
|
|
|
$organizationAddressPostal->setAddressPostal($addressPostal);
|
|
|
$organizationAddressPostal->setType(AddressPostalOrganizationTypeEnum::ADDRESS_HEAD_OFFICE);
|
|
|
- $this->entityManager->persist($organizationAddressPostal);
|
|
|
|
|
|
return $organizationAddressPostal;
|
|
|
}
|
|
|
@@ -356,7 +348,6 @@ class OrganizationFactory
|
|
|
$contactPoint->setContactType(ContactPointTypeEnum::PRINCIPAL);
|
|
|
$contactPoint->setEmail($organizationCreationRequest->getEmail());
|
|
|
$contactPoint->setTelphone($phoneNumber);
|
|
|
- $this->entityManager->persist($contactPoint);
|
|
|
|
|
|
return $contactPoint;
|
|
|
}
|
|
|
@@ -409,7 +400,6 @@ class OrganizationFactory
|
|
|
$networkOrganization->setParent($parent);
|
|
|
$networkOrganization->setNetwork($network);
|
|
|
$networkOrganization->setStartDate(DatesUtils::new());
|
|
|
- $this->entityManager->persist($networkOrganization);
|
|
|
|
|
|
return $networkOrganization;
|
|
|
}
|
|
|
@@ -427,12 +417,10 @@ class OrganizationFactory
|
|
|
$admin->setUsername('admin' . strtolower($organizationCreationRequest->getSubdomain()));
|
|
|
$randomString = ByteString::fromRandom(32)->toString();
|
|
|
$admin->setPassword($randomString);
|
|
|
- $this->entityManager->persist($admin);
|
|
|
|
|
|
$adminAccess = new Access();
|
|
|
$adminAccess->setAdminAccess(true);
|
|
|
$adminAccess->setPerson($admin);
|
|
|
- $this->entityManager->persist($adminAccess);
|
|
|
|
|
|
return $adminAccess;
|
|
|
}
|
|
|
@@ -461,7 +449,6 @@ class OrganizationFactory
|
|
|
$cycle->setOrder($cycleData[1]);
|
|
|
$cycle->setCycleEnum($cycleData[2]);
|
|
|
$cycle->setIsSystem(false);
|
|
|
- $this->entityManager->persist($cycle);
|
|
|
$cycles[] = $cycle;
|
|
|
}
|
|
|
|
|
|
@@ -501,13 +488,10 @@ class OrganizationFactory
|
|
|
|
|
|
$contactPoint = $this->makePersonContactPoint($creationRequestData);
|
|
|
$person->addContactPoint($contactPoint);
|
|
|
-
|
|
|
- $this->entityManager->persist($person);
|
|
|
}
|
|
|
|
|
|
$access = new Access();
|
|
|
$access->setPerson($person);
|
|
|
- $this->entityManager->persist($access);
|
|
|
|
|
|
return $access;
|
|
|
}
|
|
|
@@ -531,12 +515,10 @@ class OrganizationFactory
|
|
|
|
|
|
$country = $this->countryRepository->find($organizationMemberCreationRequest->getCountryId());
|
|
|
$addressPostal->setAddressCountry($country);
|
|
|
- $this->entityManager->persist($addressPostal);
|
|
|
|
|
|
$personAddressPostal = new PersonAddressPostal();
|
|
|
$personAddressPostal->setAddressPostal($addressPostal);
|
|
|
$personAddressPostal->setType(AddressPostalPersonTypeEnum::ADDRESS_PRINCIPAL);
|
|
|
- $this->entityManager->persist($personAddressPostal);
|
|
|
|
|
|
return $personAddressPostal;
|
|
|
}
|
|
|
@@ -564,7 +546,6 @@ class OrganizationFactory
|
|
|
$contactPoint->setMobilPhone($mobileNumber);
|
|
|
}
|
|
|
|
|
|
- $this->entityManager->persist($contactPoint);
|
|
|
return $contactPoint;
|
|
|
}
|
|
|
|
|
|
@@ -573,8 +554,6 @@ class OrganizationFactory
|
|
|
$subdomain = new Subdomain();
|
|
|
$subdomain->setSubdomain($organizationCreationRequest->getSubdomain());
|
|
|
$subdomain->setActive(true);
|
|
|
- $this->entityManager->persist($subdomain);
|
|
|
-
|
|
|
return $subdomain;
|
|
|
}
|
|
|
|