|
|
@@ -88,8 +88,8 @@ class OrganizationFactory
|
|
|
|
|
|
try {
|
|
|
// On vérifie si cette organisation n'existe pas déjà
|
|
|
- $this->assertNotExisting($organizationCreationRequest);
|
|
|
- dd('yo');
|
|
|
+ $this->interruptIfOrganizationExists($organizationCreationRequest);
|
|
|
+
|
|
|
// On vérifie la validité et la disponibilité du sous domaine
|
|
|
$this->validateSubdomain($organizationCreationRequest->getSubdomain());
|
|
|
$this->logger->info("Subdomain is valid and available : '" . $organizationCreationRequest->getSubdomain() . "'");
|
|
|
@@ -167,8 +167,41 @@ class OrganizationFactory
|
|
|
*
|
|
|
* @param OrganizationCreationRequest $organizationCreationRequest
|
|
|
*/
|
|
|
- protected function assertNotExisting(OrganizationCreationRequest $organizationCreationRequest): void
|
|
|
+ protected function interruptIfOrganizationExists(OrganizationCreationRequest $organizationCreationRequest): void
|
|
|
{
|
|
|
+ if (
|
|
|
+ $organizationCreationRequest->getSiretNumber() &&
|
|
|
+ $this->organizationIdentificationRepository->findOneBy(
|
|
|
+ ['siretNumber' => $organizationCreationRequest->getSiretNumber()]
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ throw new \RuntimeException(
|
|
|
+ "This siret number is already registered : '" . $organizationCreationRequest->getSiretNumber()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if (
|
|
|
+ $organizationCreationRequest->getWaldecNumber() &&
|
|
|
+ $this->organizationIdentificationRepository->findOneBy(
|
|
|
+ ['waldecNumber' => $organizationCreationRequest->getWaldecNumber()]
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ throw new \RuntimeException(
|
|
|
+ "This RNA identifier (waldec number) is already registered : '" . $organizationCreationRequest->getWaldecNumber()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if (
|
|
|
+ $organizationCreationRequest->getIdentifier() &&
|
|
|
+ $this->organizationIdentificationRepository->findOneBy(
|
|
|
+ ['identifier' => $organizationCreationRequest->getIdentifier()]
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ throw new \RuntimeException(
|
|
|
+ "This CMF identifier is already registered : '" . $organizationCreationRequest->getIdentifier()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
$normalizedName = preg_replace(
|
|
|
"/[^a-z0-9]+/",
|
|
|
"+",
|