|
@@ -28,6 +28,7 @@ use App\Repository\Organization\OrganizationRepository;
|
|
|
use App\Repository\Person\PersonRepository;
|
|
use App\Repository\Person\PersonRepository;
|
|
|
use App\Service\ApiLegacy\ApiLegacyRequestService;
|
|
use App\Service\ApiLegacy\ApiLegacyRequestService;
|
|
|
use App\Service\Dolibarr\DolibarrApiService;
|
|
use App\Service\Dolibarr\DolibarrApiService;
|
|
|
|
|
+use App\Service\Organization\Utils as OrganizationUtils;
|
|
|
use App\Service\Typo3\BindFileService;
|
|
use App\Service\Typo3\BindFileService;
|
|
|
use App\Service\Typo3\SubdomainService;
|
|
use App\Service\Typo3\SubdomainService;
|
|
|
use App\Service\Typo3\Typo3Service;
|
|
use App\Service\Typo3\Typo3Service;
|
|
@@ -44,8 +45,6 @@ use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
|
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
|
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
|
|
use Symfony\Contracts\Service\Attribute\Required;
|
|
use Symfony\Contracts\Service\Attribute\Required;
|
|
|
-use Throwable;
|
|
|
|
|
-use App\Service\Organization\Utils as OrganizationUtils;
|
|
|
|
|
|
|
|
|
|
class OrganizationFactory
|
|
class OrganizationFactory
|
|
|
{
|
|
{
|
|
@@ -54,17 +53,17 @@ class OrganizationFactory
|
|
|
protected PhoneNumberUtil $phoneNumberUtil;
|
|
protected PhoneNumberUtil $phoneNumberUtil;
|
|
|
|
|
|
|
|
public function __construct(
|
|
public function __construct(
|
|
|
- private readonly SubdomainService $subdomainService,
|
|
|
|
|
- private readonly OrganizationRepository $organizationRepository,
|
|
|
|
|
- private readonly CountryRepository $countryRepository,
|
|
|
|
|
- private readonly OrganizationUtils $organizationUtils,
|
|
|
|
|
- private readonly Typo3Service $typo3Service,
|
|
|
|
|
- private readonly DolibarrApiService $dolibarrApiService,
|
|
|
|
|
- private readonly EntityManagerInterface $entityManager,
|
|
|
|
|
- private readonly PersonRepository $personRepository,
|
|
|
|
|
- private readonly BindFileService $bindFileService,
|
|
|
|
|
|
|
+ private readonly SubdomainService $subdomainService,
|
|
|
|
|
+ private readonly OrganizationRepository $organizationRepository,
|
|
|
|
|
+ private readonly CountryRepository $countryRepository,
|
|
|
|
|
+ private readonly OrganizationUtils $organizationUtils,
|
|
|
|
|
+ private readonly Typo3Service $typo3Service,
|
|
|
|
|
+ private readonly DolibarrApiService $dolibarrApiService,
|
|
|
|
|
+ private readonly EntityManagerInterface $entityManager,
|
|
|
|
|
+ private readonly PersonRepository $personRepository,
|
|
|
|
|
+ private readonly BindFileService $bindFileService,
|
|
|
private readonly OrganizationIdentificationRepository $organizationIdentificationRepository,
|
|
private readonly OrganizationIdentificationRepository $organizationIdentificationRepository,
|
|
|
- private readonly ApiLegacyRequestService $apiLegacyRequestService
|
|
|
|
|
|
|
+ private readonly ApiLegacyRequestService $apiLegacyRequestService,
|
|
|
) {
|
|
) {
|
|
|
$this->phoneNumberUtil = PhoneNumberUtil::getInstance();
|
|
$this->phoneNumberUtil = PhoneNumberUtil::getInstance();
|
|
|
}
|
|
}
|
|
@@ -77,17 +76,15 @@ class OrganizationFactory
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Créé une nouvelle organisation à partir des données contenues dans une OrganizationCreationRequest
|
|
|
|
|
|
|
+ * Créé une nouvelle organisation à partir des données contenues dans une OrganizationCreationRequest.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest
|
|
|
|
|
- * @return Organization
|
|
|
|
|
* @throws TransportExceptionInterface
|
|
* @throws TransportExceptionInterface
|
|
|
- * @throws Throwable
|
|
|
|
|
|
|
+ * @throws \Throwable
|
|
|
*/
|
|
*/
|
|
|
public function create(OrganizationCreationRequest $organizationCreationRequest): Organization
|
|
public function create(OrganizationCreationRequest $organizationCreationRequest): Organization
|
|
|
{
|
|
{
|
|
|
$this->logger->info(
|
|
$this->logger->info(
|
|
|
- "Start the creation of a new organization named '" . $organizationCreationRequest->getName() . "'"
|
|
|
|
|
|
|
+ "Start the creation of a new organization named '".$organizationCreationRequest->getName()."'"
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
$this->entityManager->beginTransaction();
|
|
$this->entityManager->beginTransaction();
|
|
@@ -98,11 +95,11 @@ class OrganizationFactory
|
|
|
|
|
|
|
|
// On vérifie la validité et la disponibilité du sous domaine
|
|
// On vérifie la validité et la disponibilité du sous domaine
|
|
|
$this->validateSubdomain($organizationCreationRequest->getSubdomain());
|
|
$this->validateSubdomain($organizationCreationRequest->getSubdomain());
|
|
|
- $this->logger->info("Subdomain is valid and available : '" . $organizationCreationRequest->getSubdomain() . "'");
|
|
|
|
|
|
|
+ $this->logger->info("Subdomain is valid and available : '".$organizationCreationRequest->getSubdomain()."'");
|
|
|
|
|
|
|
|
// On construit l'organisation et ses relations
|
|
// On construit l'organisation et ses relations
|
|
|
$organization = $this->makeOrganizationWithRelations($organizationCreationRequest);
|
|
$organization = $this->makeOrganizationWithRelations($organizationCreationRequest);
|
|
|
- $this->logger->info("Organization created with all its relations");
|
|
|
|
|
|
|
+ $this->logger->info('Organization created with all its relations');
|
|
|
|
|
|
|
|
// On persiste et on commit, les objets liés seront persistés en cascade
|
|
// On persiste et on commit, les objets liés seront persistés en cascade
|
|
|
$this->entityManager->persist($organization);
|
|
$this->entityManager->persist($organization);
|
|
@@ -110,12 +107,11 @@ class OrganizationFactory
|
|
|
$this->entityManager->flush();
|
|
$this->entityManager->flush();
|
|
|
|
|
|
|
|
$this->entityManager->commit();
|
|
$this->entityManager->commit();
|
|
|
- $this->logger->debug(" - New entities committed in DB");
|
|
|
|
|
-
|
|
|
|
|
- $this->logger->info("Organization persisted in the DB");
|
|
|
|
|
|
|
+ $this->logger->debug(' - New entities committed in DB');
|
|
|
|
|
|
|
|
|
|
+ $this->logger->info('Organization persisted in the DB');
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
- $this->logger->critical("An error happened, operation cancelled\n" . $e);
|
|
|
|
|
|
|
+ $this->logger->critical("An error happened, operation cancelled\n".$e);
|
|
|
$this->entityManager->rollback();
|
|
$this->entityManager->rollback();
|
|
|
throw $e;
|
|
throw $e;
|
|
|
}
|
|
}
|
|
@@ -128,9 +124,9 @@ class OrganizationFactory
|
|
|
$organization,
|
|
$organization,
|
|
|
$organizationCreationRequest->isClient()
|
|
$organizationCreationRequest->isClient()
|
|
|
);
|
|
);
|
|
|
- $this->logger->info("New dolibarr structure created (uid : " . $dolibarrId . ")");
|
|
|
|
|
|
|
+ $this->logger->info('New dolibarr structure created (uid : '.$dolibarrId.')');
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
- $this->logger->critical("An error happened while creating the dolibarr society, please proceed manually.");
|
|
|
|
|
|
|
+ $this->logger->critical('An error happened while creating the dolibarr society, please proceed manually.');
|
|
|
$this->logger->debug($e);
|
|
$this->logger->debug($e);
|
|
|
$withError = true;
|
|
$withError = true;
|
|
|
}
|
|
}
|
|
@@ -138,9 +134,9 @@ class OrganizationFactory
|
|
|
// Register the subdomain into the BindFile (takes up to 5min to take effect)
|
|
// Register the subdomain into the BindFile (takes up to 5min to take effect)
|
|
|
try {
|
|
try {
|
|
|
$this->bindFileService->registerSubdomain($organizationCreationRequest->getSubdomain());
|
|
$this->bindFileService->registerSubdomain($organizationCreationRequest->getSubdomain());
|
|
|
- $this->logger->info("Subdomain registered");
|
|
|
|
|
|
|
+ $this->logger->info('Subdomain registered');
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
- $this->logger->critical("An error happened while updating the bind file, please proceed manually.");
|
|
|
|
|
|
|
+ $this->logger->critical('An error happened while updating the bind file, please proceed manually.');
|
|
|
$this->logger->debug($e);
|
|
$this->logger->debug($e);
|
|
|
$withError = true;
|
|
$withError = true;
|
|
|
}
|
|
}
|
|
@@ -148,29 +144,29 @@ class OrganizationFactory
|
|
|
if ($organizationCreationRequest->getCreateWebsite()) {
|
|
if ($organizationCreationRequest->getCreateWebsite()) {
|
|
|
try {
|
|
try {
|
|
|
$rootUid = $this->createTypo3Website($organization);
|
|
$rootUid = $this->createTypo3Website($organization);
|
|
|
- $this->logger->info("Typo3 website created (root uid: " . $rootUid . ")");
|
|
|
|
|
|
|
+ $this->logger->info('Typo3 website created (root uid: '.$rootUid.')');
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
- $this->logger->critical("An error happened while creating the typo3 website, please proceed manually.");
|
|
|
|
|
|
|
+ $this->logger->critical('An error happened while creating the typo3 website, please proceed manually.');
|
|
|
$this->logger->debug($e);
|
|
$this->logger->debug($e);
|
|
|
$withError = true;
|
|
$withError = true;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- $this->logger->warning("Typo3 website creation was not required");
|
|
|
|
|
|
|
+ $this->logger->warning('Typo3 website creation was not required');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Création de l'organisation dans la base adminassos (géré par la V1)
|
|
// Création de l'organisation dans la base adminassos (géré par la V1)
|
|
|
try {
|
|
try {
|
|
|
$this->updateAdminassosDb($organization);
|
|
$this->updateAdminassosDb($organization);
|
|
|
- $this->logger->info("Adminassos db updated");
|
|
|
|
|
|
|
+ $this->logger->info('Adminassos db updated');
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
- $this->logger->critical("An error happened while updating the adminassos db, please proceed manually.");
|
|
|
|
|
|
|
+ $this->logger->critical('An error happened while updating the adminassos db, please proceed manually.');
|
|
|
$this->logger->debug($e);
|
|
$this->logger->debug($e);
|
|
|
$withError = true;
|
|
$withError = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($withError) {
|
|
if ($withError) {
|
|
|
$organizationCreationRequest->setStatus(OrganizationCreationRequest::STATUS_OK_WITH_ERRORS);
|
|
$organizationCreationRequest->setStatus(OrganizationCreationRequest::STATUS_OK_WITH_ERRORS);
|
|
|
- $this->logger->warning("-- Operation ended with errors, check the logs for more information --");
|
|
|
|
|
|
|
+ $this->logger->warning('-- Operation ended with errors, check the logs for more information --');
|
|
|
} else {
|
|
} else {
|
|
|
$organizationCreationRequest->setStatus(OrganizationCreationRequest::STATUS_OK);
|
|
$organizationCreationRequest->setStatus(OrganizationCreationRequest::STATUS_OK);
|
|
|
}
|
|
}
|
|
@@ -179,43 +175,35 @@ class OrganizationFactory
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Lève une exception si cette organisation existe déjà
|
|
|
|
|
- *
|
|
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest
|
|
|
|
|
|
|
+ * Lève une exception si cette organisation existe déjà.
|
|
|
*/
|
|
*/
|
|
|
protected function interruptIfOrganizationExists(OrganizationCreationRequest $organizationCreationRequest): void
|
|
protected function interruptIfOrganizationExists(OrganizationCreationRequest $organizationCreationRequest): void
|
|
|
{
|
|
{
|
|
|
if (
|
|
if (
|
|
|
- $organizationCreationRequest->getSiretNumber() &&
|
|
|
|
|
- $this->organizationIdentificationRepository->findOneBy(
|
|
|
|
|
|
|
+ $organizationCreationRequest->getSiretNumber()
|
|
|
|
|
+ && $this->organizationIdentificationRepository->findOneBy(
|
|
|
['siretNumber' => $organizationCreationRequest->getSiretNumber()]
|
|
['siretNumber' => $organizationCreationRequest->getSiretNumber()]
|
|
|
)
|
|
)
|
|
|
) {
|
|
) {
|
|
|
- throw new \RuntimeException(
|
|
|
|
|
- "This siret number is already registered : '" . $organizationCreationRequest->getSiretNumber() . "'"
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ throw new \RuntimeException("This siret number is already registered : '".$organizationCreationRequest->getSiretNumber()."'");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
if (
|
|
|
- $organizationCreationRequest->getWaldecNumber() &&
|
|
|
|
|
- $this->organizationIdentificationRepository->findOneBy(
|
|
|
|
|
|
|
+ $organizationCreationRequest->getWaldecNumber()
|
|
|
|
|
+ && $this->organizationIdentificationRepository->findOneBy(
|
|
|
['waldecNumber' => $organizationCreationRequest->getWaldecNumber()]
|
|
['waldecNumber' => $organizationCreationRequest->getWaldecNumber()]
|
|
|
)
|
|
)
|
|
|
) {
|
|
) {
|
|
|
- throw new \RuntimeException(
|
|
|
|
|
- "This RNA identifier (waldec number) is already registered : '" . $organizationCreationRequest->getWaldecNumber() . "'"
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ throw new \RuntimeException("This RNA identifier (waldec number) is already registered : '".$organizationCreationRequest->getWaldecNumber()."'");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
if (
|
|
|
- $organizationCreationRequest->getIdentifier() &&
|
|
|
|
|
- $this->organizationIdentificationRepository->findOneBy(
|
|
|
|
|
|
|
+ $organizationCreationRequest->getIdentifier()
|
|
|
|
|
+ && $this->organizationIdentificationRepository->findOneBy(
|
|
|
['identifier' => $organizationCreationRequest->getIdentifier()]
|
|
['identifier' => $organizationCreationRequest->getIdentifier()]
|
|
|
)
|
|
)
|
|
|
) {
|
|
) {
|
|
|
- throw new \RuntimeException(
|
|
|
|
|
- "This CMF identifier is already registered : '" . $organizationCreationRequest->getIdentifier() . "'"
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ throw new \RuntimeException("This CMF identifier is already registered : '".$organizationCreationRequest->getIdentifier()."'");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$normalizedName = $this->normalizeIdentificationField($organizationCreationRequest->getName());
|
|
$normalizedName = $this->normalizeIdentificationField($organizationCreationRequest->getName());
|
|
@@ -225,16 +213,13 @@ class OrganizationFactory
|
|
|
['normalizedName' => $normalizedName, 'addressCity' => $organizationCreationRequest->getCity()]
|
|
['normalizedName' => $normalizedName, 'addressCity' => $organizationCreationRequest->getCity()]
|
|
|
)
|
|
)
|
|
|
) {
|
|
) {
|
|
|
- throw new \RuntimeException(
|
|
|
|
|
- "An organization named '" . $organizationCreationRequest->getName() .
|
|
|
|
|
- "' already exists in " . $organizationCreationRequest->getCity()
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ throw new \RuntimeException("An organization named '".$organizationCreationRequest->getName()."' already exists in ".$organizationCreationRequest->getCity());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$address = $this->normalizeIdentificationField(implode(' ', [
|
|
$address = $this->normalizeIdentificationField(implode(' ', [
|
|
|
$organizationCreationRequest->getStreetAddress1(),
|
|
$organizationCreationRequest->getStreetAddress1(),
|
|
|
$organizationCreationRequest->getStreetAddress2(),
|
|
$organizationCreationRequest->getStreetAddress2(),
|
|
|
- $organizationCreationRequest->getStreetAddress3()
|
|
|
|
|
|
|
+ $organizationCreationRequest->getStreetAddress3(),
|
|
|
]));
|
|
]));
|
|
|
|
|
|
|
|
if (
|
|
if (
|
|
@@ -242,35 +227,31 @@ class OrganizationFactory
|
|
|
[
|
|
[
|
|
|
'normalizedAddress' => $address,
|
|
'normalizedAddress' => $address,
|
|
|
'addressCity' => $organizationCreationRequest->getCity(),
|
|
'addressCity' => $organizationCreationRequest->getCity(),
|
|
|
- 'postalCode' => $organizationCreationRequest->getPostalCode()
|
|
|
|
|
|
|
+ 'postalCode' => $organizationCreationRequest->getPostalCode(),
|
|
|
]
|
|
]
|
|
|
)
|
|
)
|
|
|
) {
|
|
) {
|
|
|
- throw new \RuntimeException(
|
|
|
|
|
- 'An organization already exists at this address.'
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ throw new \RuntimeException('An organization already exists at this address.');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Vérifie la disponibilité et la validité d'un sous domaine
|
|
|
|
|
|
|
+ * Vérifie la disponibilité et la validité d'un sous domaine.
|
|
|
*
|
|
*
|
|
|
- * @param string $subdomainValue
|
|
|
|
|
- * @return void
|
|
|
|
|
* @throws \Exception
|
|
* @throws \Exception
|
|
|
*/
|
|
*/
|
|
|
protected function validateSubdomain(string $subdomainValue): void
|
|
protected function validateSubdomain(string $subdomainValue): void
|
|
|
{
|
|
{
|
|
|
if (!$this->subdomainService->isValidSubdomain($subdomainValue)) {
|
|
if (!$this->subdomainService->isValidSubdomain($subdomainValue)) {
|
|
|
- throw new \RuntimeException("Not a valid subdomain : " . $subdomainValue);
|
|
|
|
|
|
|
+ throw new \RuntimeException('Not a valid subdomain : '.$subdomainValue);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($this->subdomainService->isReservedSubdomain($subdomainValue)) {
|
|
if ($this->subdomainService->isReservedSubdomain($subdomainValue)) {
|
|
|
- throw new \RuntimeException("This subdomain is not available : " . $subdomainValue);
|
|
|
|
|
|
|
+ throw new \RuntimeException('This subdomain is not available : '.$subdomainValue);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($this->subdomainService->isRegistered($subdomainValue)) {
|
|
if ($this->subdomainService->isRegistered($subdomainValue)) {
|
|
|
- throw new \RuntimeException("This subdomain is already registered : " . $subdomainValue);
|
|
|
|
|
|
|
+ throw new \RuntimeException('This subdomain is already registered : '.$subdomainValue);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -278,53 +259,50 @@ class OrganizationFactory
|
|
|
* Créé une nouvelle instance d'organisation, et toutes les instances liées (paramètres, contact, adresses, ...),
|
|
* Créé une nouvelle instance d'organisation, et toutes les instances liées (paramètres, contact, adresses, ...),
|
|
|
* selon le contenu de la requête de création.
|
|
* selon le contenu de la requête de création.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest
|
|
|
|
|
- * @return Organization
|
|
|
|
|
- * @throws Throwable
|
|
|
|
|
|
|
+ * @throws \Throwable
|
|
|
*/
|
|
*/
|
|
|
protected function makeOrganizationWithRelations(
|
|
protected function makeOrganizationWithRelations(
|
|
|
- OrganizationCreationRequest $organizationCreationRequest
|
|
|
|
|
- ): Organization
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ OrganizationCreationRequest $organizationCreationRequest,
|
|
|
|
|
+ ): Organization {
|
|
|
// Création de l'organisation
|
|
// Création de l'organisation
|
|
|
$organization = $this->makeOrganization($organizationCreationRequest);
|
|
$organization = $this->makeOrganization($organizationCreationRequest);
|
|
|
- $this->logger->debug(" - Organization created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - Organization created');
|
|
|
|
|
|
|
|
// Création des Parameters
|
|
// Création des Parameters
|
|
|
$parameters = $this->makeParameters($organizationCreationRequest);
|
|
$parameters = $this->makeParameters($organizationCreationRequest);
|
|
|
$organization->setParameters($parameters);
|
|
$organization->setParameters($parameters);
|
|
|
- $this->logger->debug(" - Parameters created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - Parameters created');
|
|
|
|
|
|
|
|
// Création des Settings
|
|
// Création des Settings
|
|
|
$settings = $this->makeSettings($organizationCreationRequest);
|
|
$settings = $this->makeSettings($organizationCreationRequest);
|
|
|
$organization->setSettings($settings);
|
|
$organization->setSettings($settings);
|
|
|
- $this->logger->debug(" - Settings created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - Settings created');
|
|
|
|
|
|
|
|
// Création de l'adresse postale
|
|
// Création de l'adresse postale
|
|
|
$organizationAddressPostal = $this->makePostalAddress($organizationCreationRequest);
|
|
$organizationAddressPostal = $this->makePostalAddress($organizationCreationRequest);
|
|
|
$organization->addOrganizationAddressPostal($organizationAddressPostal);
|
|
$organization->addOrganizationAddressPostal($organizationAddressPostal);
|
|
|
- $this->logger->debug(" - OrganizationAddressPostal created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - OrganizationAddressPostal created');
|
|
|
|
|
|
|
|
// Création du point de contact
|
|
// Création du point de contact
|
|
|
$contactPoint = $this->makeContactPoint($organizationCreationRequest);
|
|
$contactPoint = $this->makeContactPoint($organizationCreationRequest);
|
|
|
$organization->addContactPoint($contactPoint);
|
|
$organization->addContactPoint($contactPoint);
|
|
|
- $this->logger->debug(" - ContactPoint created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - ContactPoint created');
|
|
|
|
|
|
|
|
// Rattachement au réseau
|
|
// Rattachement au réseau
|
|
|
$networkOrganization = $this->makeNetworkOrganization($organizationCreationRequest);
|
|
$networkOrganization = $this->makeNetworkOrganization($organizationCreationRequest);
|
|
|
$organization->addNetworkOrganization($networkOrganization);
|
|
$organization->addNetworkOrganization($networkOrganization);
|
|
|
- $this->logger->debug(" - NetworkOrganization created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - NetworkOrganization created');
|
|
|
|
|
|
|
|
// Créé l'admin
|
|
// Créé l'admin
|
|
|
$adminAccess = $this->makeAdminAccess($organizationCreationRequest);
|
|
$adminAccess = $this->makeAdminAccess($organizationCreationRequest);
|
|
|
$organization->addAccess($adminAccess);
|
|
$organization->addAccess($adminAccess);
|
|
|
- $this->logger->debug(" - Admin access created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - Admin access created');
|
|
|
|
|
|
|
|
// Création des cycles
|
|
// Création des cycles
|
|
|
foreach ($this->makeCycles() as $cycle) {
|
|
foreach ($this->makeCycles() as $cycle) {
|
|
|
$organization->addCycle($cycle);
|
|
$organization->addCycle($cycle);
|
|
|
}
|
|
}
|
|
|
- $this->logger->debug(" - Cycles created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - Cycles created');
|
|
|
|
|
|
|
|
// Création du président (si renseigné)
|
|
// Création du président (si renseigné)
|
|
|
$presidentCreationRequest = $organizationCreationRequest->getPresident();
|
|
$presidentCreationRequest = $organizationCreationRequest->getPresident();
|
|
@@ -338,7 +316,7 @@ class OrganizationFactory
|
|
|
$presidentAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
$presidentAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
|
|
|
|
|
|
$organization->addAccess($presidentAccess);
|
|
$organization->addAccess($presidentAccess);
|
|
|
- $this->logger->debug(" - President access created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - President access created');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Création du directeur (si renseigné)
|
|
// Création du directeur (si renseigné)
|
|
@@ -353,7 +331,7 @@ class OrganizationFactory
|
|
|
$directorAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
$directorAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
|
|
|
|
|
|
$organization->addAccess($directorAccess);
|
|
$organization->addAccess($directorAccess);
|
|
|
- $this->logger->debug(" - Director access created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - Director access created');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Création du sous-domaine
|
|
// Création du sous-domaine
|
|
@@ -363,18 +341,15 @@ class OrganizationFactory
|
|
|
// <--- Pour la rétrocompatibilité avec la v1 ; pourra être supprimé lorsque la migration sera achevée
|
|
// <--- Pour la rétrocompatibilité avec la v1 ; pourra être supprimé lorsque la migration sera achevée
|
|
|
$parameters = $organization->getParameters();
|
|
$parameters = $organization->getParameters();
|
|
|
$parameters->setSubDomain($organizationCreationRequest->getSubdomain());
|
|
$parameters->setSubDomain($organizationCreationRequest->getSubdomain());
|
|
|
- $parameters->setOtherWebsite('https://' . $organizationCreationRequest->getSubdomain() . '.opentalent.fr');
|
|
|
|
|
|
|
+ $parameters->setOtherWebsite('https://'.$organizationCreationRequest->getSubdomain().'.opentalent.fr');
|
|
|
// --->
|
|
// --->
|
|
|
- $this->logger->debug(" - Subdomain created");
|
|
|
|
|
|
|
+ $this->logger->debug(' - Subdomain created');
|
|
|
|
|
|
|
|
return $organization;
|
|
return $organization;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Créé une nouvelle instance d'organisation
|
|
|
|
|
- *
|
|
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest
|
|
|
|
|
- * @return Organization
|
|
|
|
|
|
|
+ * Créé une nouvelle instance d'organisation.
|
|
|
*/
|
|
*/
|
|
|
protected function makeOrganization(OrganizationCreationRequest $organizationCreationRequest): Organization
|
|
protected function makeOrganization(OrganizationCreationRequest $organizationCreationRequest): Organization
|
|
|
{
|
|
{
|
|
@@ -387,28 +362,32 @@ class OrganizationFactory
|
|
|
$organization->setCreationDate($organizationCreationRequest->getCreationDate());
|
|
$organization->setCreationDate($organizationCreationRequest->getCreationDate());
|
|
|
$organization->setCreateDate($organizationCreationRequest->getCreationDate());
|
|
$organization->setCreateDate($organizationCreationRequest->getCreationDate());
|
|
|
$organization->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
$organization->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
|
|
|
+
|
|
|
return $organization;
|
|
return $organization;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Create a new Parameters object from the data in an OrganizationCreationRequest
|
|
|
|
|
|
|
+ * Create a new Parameters object from the data in an OrganizationCreationRequest.
|
|
|
*
|
|
*
|
|
|
* @param OrganizationCreationRequest $organizationCreationRequest The organization creation request
|
|
* @param OrganizationCreationRequest $organizationCreationRequest The organization creation request
|
|
|
|
|
+ *
|
|
|
* @return Parameters The created Parameters object
|
|
* @return Parameters The created Parameters object
|
|
|
- * @throws Throwable If there is an error
|
|
|
|
|
|
|
+ *
|
|
|
|
|
+ * @throws \Throwable If there is an error
|
|
|
*/
|
|
*/
|
|
|
protected function makeParameters(OrganizationCreationRequest $organizationCreationRequest): Parameters
|
|
protected function makeParameters(OrganizationCreationRequest $organizationCreationRequest): Parameters
|
|
|
{
|
|
{
|
|
|
$parameters = new Parameters();
|
|
$parameters = new Parameters();
|
|
|
|
|
+
|
|
|
return $parameters;
|
|
return $parameters;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Creates a new instance of the Settings class based on the given OrganizationCreationRequest object.
|
|
* Creates a new instance of the Settings class based on the given OrganizationCreationRequest object.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest The OrganizationCreationRequest object containing the required data.
|
|
|
|
|
|
|
+ * @param OrganizationCreationRequest $organizationCreationRequest the OrganizationCreationRequest object containing the required data
|
|
|
*
|
|
*
|
|
|
- * @return Settings The newly created instance of the Settings class.
|
|
|
|
|
|
|
+ * @return Settings the newly created instance of the Settings class
|
|
|
*/
|
|
*/
|
|
|
protected function makeSettings(OrganizationCreationRequest $organizationCreationRequest): Settings
|
|
protected function makeSettings(OrganizationCreationRequest $organizationCreationRequest): Settings
|
|
|
{
|
|
{
|
|
@@ -422,21 +401,22 @@ class OrganizationFactory
|
|
|
|
|
|
|
|
$settings->setCreateDate($organizationCreationRequest->getCreationDate());
|
|
$settings->setCreateDate($organizationCreationRequest->getCreationDate());
|
|
|
$settings->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
$settings->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
|
|
|
+
|
|
|
return $settings;
|
|
return $settings;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Creates a new instance of the OrganizationAddressPostal class based on the given OrganizationCreationRequest object.
|
|
* Creates a new instance of the OrganizationAddressPostal class based on the given OrganizationCreationRequest object.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest The OrganizationCreationRequest object containing the required data.
|
|
|
|
|
|
|
+ * @param OrganizationCreationRequest $organizationCreationRequest the OrganizationCreationRequest object containing the required data
|
|
|
*
|
|
*
|
|
|
- * @return OrganizationAddressPostal The newly created instance of the OrganizationAddressPostal class.
|
|
|
|
|
|
|
+ * @return OrganizationAddressPostal the newly created instance of the OrganizationAddressPostal class
|
|
|
*/
|
|
*/
|
|
|
protected function makePostalAddress(OrganizationCreationRequest $organizationCreationRequest): OrganizationAddressPostal
|
|
protected function makePostalAddress(OrganizationCreationRequest $organizationCreationRequest): OrganizationAddressPostal
|
|
|
{
|
|
{
|
|
|
$country = $this->countryRepository->find($organizationCreationRequest->getCountryId());
|
|
$country = $this->countryRepository->find($organizationCreationRequest->getCountryId());
|
|
|
if (!$country) {
|
|
if (!$country) {
|
|
|
- throw new \RuntimeException('No country found for id ' . $organizationCreationRequest->getCountryId());
|
|
|
|
|
|
|
+ throw new \RuntimeException('No country found for id '.$organizationCreationRequest->getCountryId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$addressPostal = new AddressPostal();
|
|
$addressPostal = new AddressPostal();
|
|
@@ -461,15 +441,16 @@ class OrganizationFactory
|
|
|
/**
|
|
/**
|
|
|
* Creates a new instance of the ContactPoint class based on the given OrganizationCreationRequest object.
|
|
* Creates a new instance of the ContactPoint class based on the given OrganizationCreationRequest object.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest The OrganizationCreationRequest object containing the required data.
|
|
|
|
|
|
|
+ * @param OrganizationCreationRequest $organizationCreationRequest the OrganizationCreationRequest object containing the required data
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return ContactPoint the newly created instance of the ContactPoint class
|
|
|
*
|
|
*
|
|
|
- * @return ContactPoint The newly created instance of the ContactPoint class.
|
|
|
|
|
* @throws NumberParseException
|
|
* @throws NumberParseException
|
|
|
*/
|
|
*/
|
|
|
protected function makeContactPoint(OrganizationCreationRequest $organizationCreationRequest): ContactPoint
|
|
protected function makeContactPoint(OrganizationCreationRequest $organizationCreationRequest): ContactPoint
|
|
|
{
|
|
{
|
|
|
if (!$this->phoneNumberUtil->isPossibleNumber($organizationCreationRequest->getPhoneNumber())) {
|
|
if (!$this->phoneNumberUtil->isPossibleNumber($organizationCreationRequest->getPhoneNumber())) {
|
|
|
- throw new \RuntimeException("Phone number is invalid or missing");
|
|
|
|
|
|
|
+ throw new \RuntimeException('Phone number is invalid or missing');
|
|
|
}
|
|
}
|
|
|
$phoneNumber = $this->phoneNumberUtil->parse($organizationCreationRequest->getPhoneNumber());
|
|
$phoneNumber = $this->phoneNumberUtil->parse($organizationCreationRequest->getPhoneNumber());
|
|
|
|
|
|
|
@@ -486,29 +467,26 @@ class OrganizationFactory
|
|
|
/**
|
|
/**
|
|
|
* Creates a new instance of the NetworkOrganization class based on the given OrganizationCreationRequest object.
|
|
* Creates a new instance of the NetworkOrganization class based on the given OrganizationCreationRequest object.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest The OrganizationCreationRequest object containing the required data.
|
|
|
|
|
|
|
+ * @param OrganizationCreationRequest $organizationCreationRequest the OrganizationCreationRequest object containing the required data
|
|
|
*
|
|
*
|
|
|
- * @return NetworkOrganization The newly created instance of the NetworkOrganization class.
|
|
|
|
|
|
|
+ * @return NetworkOrganization the newly created instance of the NetworkOrganization class
|
|
|
*
|
|
*
|
|
|
- * @throws \RuntimeException|\Exception if no parent organization is found for the given parent ID or if no network is found for the given network ID.
|
|
|
|
|
|
|
+ * @throws \RuntimeException|\Exception if no parent organization is found for the given parent ID or if no network is found for the given network ID
|
|
|
*/
|
|
*/
|
|
|
protected function makeNetworkOrganization(OrganizationCreationRequest $organizationCreationRequest): NetworkOrganization
|
|
protected function makeNetworkOrganization(OrganizationCreationRequest $organizationCreationRequest): NetworkOrganization
|
|
|
{
|
|
{
|
|
|
$parent = $this->organizationRepository->find($organizationCreationRequest->getParentId());
|
|
$parent = $this->organizationRepository->find($organizationCreationRequest->getParentId());
|
|
|
if (!$parent) {
|
|
if (!$parent) {
|
|
|
- throw new \RuntimeException('No parent organization found for id ' . $organizationCreationRequest->getParentId());
|
|
|
|
|
|
|
+ throw new \RuntimeException('No parent organization found for id '.$organizationCreationRequest->getParentId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($parent->getSettings()->getProduct() !== SettingsProductEnum::MANAGER) {
|
|
if ($parent->getSettings()->getProduct() !== SettingsProductEnum::MANAGER) {
|
|
|
- throw new \RuntimeException(
|
|
|
|
|
- "Parent organization must have the product 'manager' (actual product: '" .
|
|
|
|
|
- $parent->getSettings()->getProduct()->value . "')"
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ throw new \RuntimeException("Parent organization must have the product 'manager' (actual product: '".$parent->getSettings()->getProduct()->value."')");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$networkOrganization = $this->organizationUtils->getActiveNetworkOrganization($parent);
|
|
$networkOrganization = $this->organizationUtils->getActiveNetworkOrganization($parent);
|
|
|
if (!$networkOrganization) {
|
|
if (!$networkOrganization) {
|
|
|
- throw new \RuntimeException('No network found for parent ' . $organizationCreationRequest->getParentId());
|
|
|
|
|
|
|
+ throw new \RuntimeException('No network found for parent '.$organizationCreationRequest->getParentId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$network = $networkOrganization->getNetwork();
|
|
$network = $networkOrganization->getNetwork();
|
|
@@ -516,7 +494,7 @@ class OrganizationFactory
|
|
|
// Si réseau CMF, on vérifie que le matricule est valide
|
|
// Si réseau CMF, on vérifie que le matricule est valide
|
|
|
if ($network->getId() === NetworkEnum::CMF->value) {
|
|
if ($network->getId() === NetworkEnum::CMF->value) {
|
|
|
if (!preg_match("/FR\d{12}/", $organizationCreationRequest->getIdentifier())) {
|
|
if (!preg_match("/FR\d{12}/", $organizationCreationRequest->getIdentifier())) {
|
|
|
- throw new \RuntimeException("CMF identifier is missing or invalid.");
|
|
|
|
|
|
|
+ throw new \RuntimeException('CMF identifier is missing or invalid.');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -533,14 +511,14 @@ class OrganizationFactory
|
|
|
/**
|
|
/**
|
|
|
* Creates a new instance of the Access class with admin access based on the given OrganizationCreationRequest object.
|
|
* Creates a new instance of the Access class with admin access based on the given OrganizationCreationRequest object.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationCreationRequest $organizationCreationRequest The OrganizationCreationRequest object containing the required data.
|
|
|
|
|
|
|
+ * @param OrganizationCreationRequest $organizationCreationRequest the OrganizationCreationRequest object containing the required data
|
|
|
*
|
|
*
|
|
|
- * @return Access The newly created instance of the Access class with admin access.
|
|
|
|
|
|
|
+ * @return Access the newly created instance of the Access class with admin access
|
|
|
*/
|
|
*/
|
|
|
protected function makeAdminAccess(OrganizationCreationRequest $organizationCreationRequest): Access
|
|
protected function makeAdminAccess(OrganizationCreationRequest $organizationCreationRequest): Access
|
|
|
{
|
|
{
|
|
|
$admin = new Person();
|
|
$admin = new Person();
|
|
|
- $admin->setUsername('admin' . strtolower($organizationCreationRequest->getSubdomain()));
|
|
|
|
|
|
|
+ $admin->setUsername('admin'.strtolower($organizationCreationRequest->getSubdomain()));
|
|
|
$randomString = ByteString::fromRandom(32)->toString();
|
|
$randomString = ByteString::fromRandom(32)->toString();
|
|
|
$admin->setPassword($randomString);
|
|
$admin->setPassword($randomString);
|
|
|
|
|
|
|
@@ -556,7 +534,7 @@ class OrganizationFactory
|
|
|
/**
|
|
/**
|
|
|
* Creates an array of Cycle objects based on a predefined set of data.
|
|
* Creates an array of Cycle objects based on a predefined set of data.
|
|
|
*
|
|
*
|
|
|
- * @return Cycle[] An array of Cycle objects.
|
|
|
|
|
|
|
+ * @return Cycle[] an array of Cycle objects
|
|
|
*/
|
|
*/
|
|
|
protected function makeCycles(): array
|
|
protected function makeCycles(): array
|
|
|
{
|
|
{
|
|
@@ -586,16 +564,17 @@ class OrganizationFactory
|
|
|
/**
|
|
/**
|
|
|
* Creates an Access object based on the given OrganizationMemberCreationRequest.
|
|
* Creates an Access object based on the given OrganizationMemberCreationRequest.
|
|
|
*
|
|
*
|
|
|
- * @param int|OrganizationMemberCreationRequest $creationRequestData The request object containing the
|
|
|
|
|
|
|
+ * @param int|OrganizationMemberCreationRequest $creationRequestData the request object containing the
|
|
|
* necessary data for creating a Person object,
|
|
* necessary data for creating a Person object,
|
|
|
- * or the id of an existing one.
|
|
|
|
|
- * @return Access The created Access object.
|
|
|
|
|
|
|
+ * or the id of an existing one
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return Access the created Access object
|
|
|
|
|
+ *
|
|
|
* @throws NumberParseException
|
|
* @throws NumberParseException
|
|
|
*/
|
|
*/
|
|
|
protected function makeAccess(
|
|
protected function makeAccess(
|
|
|
- int | OrganizationMemberCreationRequest $creationRequestData
|
|
|
|
|
- ): Access
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ int|OrganizationMemberCreationRequest $creationRequestData,
|
|
|
|
|
+ ): Access {
|
|
|
if (is_int($creationRequestData)) {
|
|
if (is_int($creationRequestData)) {
|
|
|
$person = $this->personRepository->find($creationRequestData);
|
|
$person = $this->personRepository->find($creationRequestData);
|
|
|
} else {
|
|
} else {
|
|
@@ -630,10 +609,11 @@ class OrganizationFactory
|
|
|
/**
|
|
/**
|
|
|
* Creates a PersonAddressPostal object based on the given OrganizationMemberCreationRequest.
|
|
* Creates a PersonAddressPostal object based on the given OrganizationMemberCreationRequest.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationMemberCreationRequest $organizationMemberCreationRequest The request object containing the
|
|
|
|
|
|
|
+ * @param OrganizationMemberCreationRequest $organizationMemberCreationRequest the request object containing the
|
|
|
* necessary data for creating a
|
|
* necessary data for creating a
|
|
|
- * PersonAddressPostal object.
|
|
|
|
|
- * @return PersonAddressPostal The created PersonAddressPostal object.
|
|
|
|
|
|
|
+ * PersonAddressPostal object
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return PersonAddressPostal the created PersonAddressPostal object
|
|
|
*/
|
|
*/
|
|
|
protected function makePersonPostalAddress(OrganizationMemberCreationRequest $organizationMemberCreationRequest): PersonAddressPostal
|
|
protected function makePersonPostalAddress(OrganizationMemberCreationRequest $organizationMemberCreationRequest): PersonAddressPostal
|
|
|
{
|
|
{
|
|
@@ -661,9 +641,10 @@ class OrganizationFactory
|
|
|
/**
|
|
/**
|
|
|
* Creates a new instance of the ContactPoint class based on the given OrganizationCreationRequest object.
|
|
* Creates a new instance of the ContactPoint class based on the given OrganizationCreationRequest object.
|
|
|
*
|
|
*
|
|
|
- * @param OrganizationMemberCreationRequest $organizationMemberCreationRequest The OrganizationMemberCreationRequest object containing the required data.
|
|
|
|
|
|
|
+ * @param OrganizationMemberCreationRequest $organizationMemberCreationRequest the OrganizationMemberCreationRequest object containing the required data
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return ContactPoint the newly created instance of the ContactPoint class
|
|
|
*
|
|
*
|
|
|
- * @return ContactPoint The newly created instance of the ContactPoint class.
|
|
|
|
|
* @throws NumberParseException
|
|
* @throws NumberParseException
|
|
|
*/
|
|
*/
|
|
|
protected function makePersonContactPoint(OrganizationMemberCreationRequest $organizationMemberCreationRequest): ContactPoint
|
|
protected function makePersonContactPoint(OrganizationMemberCreationRequest $organizationMemberCreationRequest): ContactPoint
|
|
@@ -683,6 +664,7 @@ class OrganizationFactory
|
|
|
|
|
|
|
|
$contactPoint->setCreateDate($organizationMemberCreationRequest->getCreationDate());
|
|
$contactPoint->setCreateDate($organizationMemberCreationRequest->getCreationDate());
|
|
|
$contactPoint->setCreatedBy($organizationMemberCreationRequest->getAuthorId());
|
|
$contactPoint->setCreatedBy($organizationMemberCreationRequest->getAuthorId());
|
|
|
|
|
+
|
|
|
return $contactPoint;
|
|
return $contactPoint;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -691,18 +673,20 @@ class OrganizationFactory
|
|
|
$subdomain = new Subdomain();
|
|
$subdomain = new Subdomain();
|
|
|
$subdomain->setSubdomain($organizationCreationRequest->getSubdomain());
|
|
$subdomain->setSubdomain($organizationCreationRequest->getSubdomain());
|
|
|
$subdomain->setActive(true);
|
|
$subdomain->setActive(true);
|
|
|
|
|
+
|
|
|
return $subdomain;
|
|
return $subdomain;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Créé le site Typo3 et retourne l'id de la page racine du site nouvellement créé, ou null en cas d'erreur
|
|
|
|
|
|
|
+ * Créé le site Typo3 et retourne l'id de la page racine du site nouvellement créé, ou null en cas d'erreur.
|
|
|
*
|
|
*
|
|
|
* @throws RedirectionExceptionInterface
|
|
* @throws RedirectionExceptionInterface
|
|
|
* @throws ClientExceptionInterface
|
|
* @throws ClientExceptionInterface
|
|
|
* @throws TransportExceptionInterface
|
|
* @throws TransportExceptionInterface
|
|
|
* @throws ServerExceptionInterface
|
|
* @throws ServerExceptionInterface
|
|
|
*/
|
|
*/
|
|
|
- protected function createTypo3Website(Organization $organization): ?int {
|
|
|
|
|
|
|
+ protected function createTypo3Website(Organization $organization): ?int
|
|
|
|
|
+ {
|
|
|
$response = $this->typo3Service->createSite($organization->getId());
|
|
$response = $this->typo3Service->createSite($organization->getId());
|
|
|
$content = json_decode($response->getContent(), true);
|
|
$content = json_decode($response->getContent(), true);
|
|
|
$rootPageUid = $content['root_uid'];
|
|
$rootPageUid = $content['root_uid'];
|
|
@@ -726,27 +710,26 @@ class OrganizationFactory
|
|
|
{
|
|
{
|
|
|
$response = $this->apiLegacyRequestService->post(
|
|
$response = $this->apiLegacyRequestService->post(
|
|
|
'/_internal/secure/organization/creation-event',
|
|
'/_internal/secure/organization/creation-event',
|
|
|
- [ 'organizationId' => $organization->getId() ]
|
|
|
|
|
|
|
+ ['organizationId' => $organization->getId()]
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
if ($response->getStatusCode() !== Response::HTTP_OK) {
|
|
if ($response->getStatusCode() !== Response::HTTP_OK) {
|
|
|
- throw new \RuntimeException('An error happened while updating the adminassos database: ' . $response->getContent());
|
|
|
|
|
|
|
+ throw new \RuntimeException('An error happened while updating the adminassos database: '.$response->getContent());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Normalise la chaine comme sont normalisées les champs de l'entité OrganizationIdentification
|
|
|
|
|
|
|
+ * Normalise la chaine comme sont normalisées les champs de l'entité OrganizationIdentification.
|
|
|
*
|
|
*
|
|
|
* @øee sql/schema-extensions/003-view_organization_identification.sql
|
|
* @øee sql/schema-extensions/003-view_organization_identification.sql
|
|
|
- *
|
|
|
|
|
- * @param string $value
|
|
|
|
|
- * @return string
|
|
|
|
|
*/
|
|
*/
|
|
|
- protected function normalizeIdentificationField(string $value): string {
|
|
|
|
|
|
|
+ protected function normalizeIdentificationField(string $value): string
|
|
|
|
|
+ {
|
|
|
$value = strtolower(trim($value));
|
|
$value = strtolower(trim($value));
|
|
|
$value = preg_replace('/[éèê]/u', 'e', $value);
|
|
$value = preg_replace('/[éèê]/u', 'e', $value);
|
|
|
$value = preg_replace('/[à]/u', 'a', $value);
|
|
$value = preg_replace('/[à]/u', 'a', $value);
|
|
|
$value = preg_replace('/[ç]/u', 'c', $value);
|
|
$value = preg_replace('/[ç]/u', 'c', $value);
|
|
|
|
|
+
|
|
|
return preg_replace('/[^a-z0-9]+/u', '+', $value);
|
|
return preg_replace('/[^a-z0-9]+/u', '+', $value);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|