|
|
@@ -5,6 +5,8 @@ namespace App\Service\Organization;
|
|
|
use App\ApiResources\Organization\OrganizationCreationRequest;
|
|
|
use App\ApiResources\Organization\OrganizationMemberCreationRequest;
|
|
|
use App\Entity\Access\Access;
|
|
|
+use App\Entity\Access\FunctionType;
|
|
|
+use App\Entity\Access\OrganizationFunction;
|
|
|
use App\Entity\Core\AddressPostal;
|
|
|
use App\Entity\Core\ContactPoint;
|
|
|
use App\Entity\Education\Cycle;
|
|
|
@@ -16,12 +18,14 @@ use App\Entity\Organization\Settings;
|
|
|
use App\Entity\Organization\Subdomain;
|
|
|
use App\Entity\Person\Person;
|
|
|
use App\Entity\Person\PersonAddressPostal;
|
|
|
+use App\Enum\Access\FunctionEnum;
|
|
|
use App\Enum\Core\ContactPointTypeEnum;
|
|
|
use App\Enum\Education\CycleEnum;
|
|
|
use App\Enum\Network\NetworkEnum;
|
|
|
use App\Enum\Organization\AddressPostalOrganizationTypeEnum;
|
|
|
use App\Enum\Organization\SettingsProductEnum;
|
|
|
use App\Enum\Person\AddressPostalPersonTypeEnum;
|
|
|
+use App\Repository\Access\FunctionTypeRepository;
|
|
|
use App\Repository\Core\CountryRepository;
|
|
|
use App\Repository\Organization\OrganizationIdentificationRepository;
|
|
|
use App\Repository\Organization\OrganizationRepository;
|
|
|
@@ -64,6 +68,7 @@ class OrganizationFactory
|
|
|
private readonly BindFileService $bindFileService,
|
|
|
private readonly OrganizationIdentificationRepository $organizationIdentificationRepository,
|
|
|
private readonly ApiLegacyRequestService $apiLegacyRequestService,
|
|
|
+ private readonly FunctionTypeRepository $functionTypeRepository,
|
|
|
) {
|
|
|
$this->phoneNumberUtil = PhoneNumberUtil::getInstance();
|
|
|
}
|
|
|
@@ -307,13 +312,12 @@ class OrganizationFactory
|
|
|
// Création du président (si renseigné)
|
|
|
$presidentCreationRequest = $organizationCreationRequest->getPresident();
|
|
|
if ($presidentCreationRequest !== null) {
|
|
|
- $presidentCreationRequest->setCreationDate($organizationCreationRequest->getCreationDate());
|
|
|
- $presidentCreationRequest->setAuthorId($organizationCreationRequest->getAuthorId());
|
|
|
-
|
|
|
- $presidentAccess = $this->makeAccess($presidentCreationRequest);
|
|
|
-
|
|
|
- $presidentAccess->setCreateDate($organizationCreationRequest->getCreationDate());
|
|
|
- $presidentAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
|
+ $presidentAccess = $this->makeAccess(
|
|
|
+ $presidentCreationRequest,
|
|
|
+ FunctionEnum::PRESIDENT,
|
|
|
+ $organizationCreationRequest->getCreationDate(),
|
|
|
+ $organizationCreationRequest->getAuthorId()
|
|
|
+ );
|
|
|
|
|
|
$organization->addAccess($presidentAccess);
|
|
|
$this->logger->debug(' - President access created');
|
|
|
@@ -322,13 +326,12 @@ class OrganizationFactory
|
|
|
// Création du directeur (si renseigné)
|
|
|
$directorCreationRequest = $organizationCreationRequest->getDirector();
|
|
|
if ($directorCreationRequest !== null) {
|
|
|
- $directorCreationRequest->setCreationDate($organizationCreationRequest->getCreationDate());
|
|
|
- $directorCreationRequest->setAuthorId($organizationCreationRequest->getAuthorId());
|
|
|
-
|
|
|
- $directorAccess = $this->makeAccess($directorCreationRequest);
|
|
|
-
|
|
|
- $directorAccess->setCreateDate($organizationCreationRequest->getCreationDate());
|
|
|
- $directorAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
|
+ $directorAccess = $this->makeAccess(
|
|
|
+ $directorCreationRequest,
|
|
|
+ FunctionEnum::DIRECTOR,
|
|
|
+ $organizationCreationRequest->getCreationDate(),
|
|
|
+ $organizationCreationRequest->getAuthorId()
|
|
|
+ );
|
|
|
|
|
|
$organization->addAccess($directorAccess);
|
|
|
$this->logger->debug(' - Director access created');
|
|
|
@@ -582,6 +585,9 @@ class OrganizationFactory
|
|
|
*/
|
|
|
protected function makeAccess(
|
|
|
int|OrganizationMemberCreationRequest $creationRequestData,
|
|
|
+ FunctionEnum $function,
|
|
|
+ \DateTime $creationDate,
|
|
|
+ int|null $authorId
|
|
|
): Access {
|
|
|
if (is_int($creationRequestData)) {
|
|
|
$person = $this->personRepository->find($creationRequestData);
|
|
|
@@ -608,13 +614,26 @@ class OrganizationFactory
|
|
|
$contactPoint = $this->makePersonContactPoint($creationRequestData);
|
|
|
$person->addContactPoint($contactPoint);
|
|
|
|
|
|
- $person->setCreateDate($creationRequestData->getCreationDate());
|
|
|
- $person->setCreatedBy($creationRequestData->getAuthorId());
|
|
|
+ $person->setCreateDate($creationDate);
|
|
|
+ $person->setCreatedBy($authorId);
|
|
|
}
|
|
|
|
|
|
$access = new Access();
|
|
|
$access->setPerson($person);
|
|
|
|
|
|
+ $functionType = $this->functionTypeRepository->findOneBy(['mission' => $function]);
|
|
|
+
|
|
|
+ $organizationFunction = new OrganizationFunction();
|
|
|
+ $organizationFunction->setFunctionType($functionType);
|
|
|
+ $organizationFunction->setStartDate($creationDate);
|
|
|
+ $organizationFunction->setCreateDate($creationDate);
|
|
|
+ $organizationFunction->setCreatedBy($authorId);
|
|
|
+
|
|
|
+ $access->addOrganizationFunction($organizationFunction);
|
|
|
+
|
|
|
+ $access->setCreateDate($creationDate);
|
|
|
+ $access->setCreatedBy($authorId);
|
|
|
+
|
|
|
return $access;
|
|
|
}
|
|
|
|