|
@@ -5,7 +5,6 @@ namespace App\Service\Organization;
|
|
|
use App\ApiResources\Organization\OrganizationCreationRequest;
|
|
use App\ApiResources\Organization\OrganizationCreationRequest;
|
|
|
use App\ApiResources\Organization\OrganizationMemberCreationRequest;
|
|
use App\ApiResources\Organization\OrganizationMemberCreationRequest;
|
|
|
use App\Entity\Access\Access;
|
|
use App\Entity\Access\Access;
|
|
|
-use App\Entity\Access\FunctionType;
|
|
|
|
|
use App\Entity\Access\OrganizationFunction;
|
|
use App\Entity\Access\OrganizationFunction;
|
|
|
use App\Entity\Core\AddressPostal;
|
|
use App\Entity\Core\AddressPostal;
|
|
|
use App\Entity\Core\ContactPoint;
|
|
use App\Entity\Core\ContactPoint;
|
|
@@ -530,7 +529,7 @@ class OrganizationFactory
|
|
|
$adminAccess->setAdminAccess(true);
|
|
$adminAccess->setAdminAccess(true);
|
|
|
$adminAccess->setPerson($admin);
|
|
$adminAccess->setPerson($admin);
|
|
|
$adminAccess->setLoginEnabled(true);
|
|
$adminAccess->setLoginEnabled(true);
|
|
|
- $adminAccess->setRoles(["ROLE_ADMIN","ROLE_ADMIN_CORE"]);
|
|
|
|
|
|
|
+ $adminAccess->setRoles(['ROLE_ADMIN', 'ROLE_ADMIN_CORE']);
|
|
|
$adminAccess->setCreateDate($organizationCreationRequest->getCreationDate());
|
|
$adminAccess->setCreateDate($organizationCreationRequest->getCreationDate());
|
|
|
$adminAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
$adminAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
|
|
|
|
|
|
|
@@ -587,7 +586,7 @@ class OrganizationFactory
|
|
|
int|OrganizationMemberCreationRequest $creationRequestData,
|
|
int|OrganizationMemberCreationRequest $creationRequestData,
|
|
|
FunctionEnum $function,
|
|
FunctionEnum $function,
|
|
|
\DateTime $creationDate,
|
|
\DateTime $creationDate,
|
|
|
- int|null $authorId
|
|
|
|
|
|
|
+ ?int $authorId,
|
|
|
): Access {
|
|
): Access {
|
|
|
if (is_int($creationRequestData)) {
|
|
if (is_int($creationRequestData)) {
|
|
|
$person = $this->personRepository->find($creationRequestData);
|
|
$person = $this->personRepository->find($creationRequestData);
|
|
@@ -595,7 +594,7 @@ class OrganizationFactory
|
|
|
$person = new Person();
|
|
$person = new Person();
|
|
|
|
|
|
|
|
if ($this->personRepository->findOneBy(['username' => $creationRequestData->getUsername()])) {
|
|
if ($this->personRepository->findOneBy(['username' => $creationRequestData->getUsername()])) {
|
|
|
- throw new \RuntimeException('Username already in use : ' . $creationRequestData->getUsername());
|
|
|
|
|
|
|
+ throw new \RuntimeException('Username already in use : '.$creationRequestData->getUsername());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$person->setUsername($creationRequestData->getUsername());
|
|
$person->setUsername($creationRequestData->getUsername());
|
|
@@ -649,9 +648,8 @@ class OrganizationFactory
|
|
|
protected function makePersonPostalAddress(
|
|
protected function makePersonPostalAddress(
|
|
|
OrganizationMemberCreationRequest $organizationMemberCreationRequest,
|
|
OrganizationMemberCreationRequest $organizationMemberCreationRequest,
|
|
|
\DateTime $creationDate,
|
|
\DateTime $creationDate,
|
|
|
- int|null $authorId
|
|
|
|
|
- ): PersonAddressPostal
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ ?int $authorId,
|
|
|
|
|
+ ): PersonAddressPostal {
|
|
|
$addressPostal = new AddressPostal();
|
|
$addressPostal = new AddressPostal();
|
|
|
$addressPostal->setStreetAddress($organizationMemberCreationRequest->getStreetAddress1());
|
|
$addressPostal->setStreetAddress($organizationMemberCreationRequest->getStreetAddress1());
|
|
|
$addressPostal->setStreetAddressSecond($organizationMemberCreationRequest->getStreetAddress2());
|
|
$addressPostal->setStreetAddressSecond($organizationMemberCreationRequest->getStreetAddress2());
|
|
@@ -685,16 +683,15 @@ class OrganizationFactory
|
|
|
protected function makePersonContactPoint(
|
|
protected function makePersonContactPoint(
|
|
|
OrganizationMemberCreationRequest $organizationMemberCreationRequest,
|
|
OrganizationMemberCreationRequest $organizationMemberCreationRequest,
|
|
|
\DateTime $creationDate,
|
|
\DateTime $creationDate,
|
|
|
- int|null $authorId
|
|
|
|
|
- ): ContactPoint
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ ?int $authorId,
|
|
|
|
|
+ ): ContactPoint {
|
|
|
if (!$this->phoneNumberUtil->isPossibleNumber($organizationMemberCreationRequest->getPhone())) {
|
|
if (!$this->phoneNumberUtil->isPossibleNumber($organizationMemberCreationRequest->getPhone())) {
|
|
|
- throw new \RuntimeException('Phone number is invalid or missing (person: ' . $organizationMemberCreationRequest->getUsername() . ')');
|
|
|
|
|
|
|
+ throw new \RuntimeException('Phone number is invalid or missing (person: '.$organizationMemberCreationRequest->getUsername().')');
|
|
|
}
|
|
}
|
|
|
if (
|
|
if (
|
|
|
- $organizationMemberCreationRequest->getMobile() !== null &&
|
|
|
|
|
- !$this->phoneNumberUtil->isPossibleNumber($organizationMemberCreationRequest->getMobile())) {
|
|
|
|
|
- throw new \RuntimeException('Mobile phone number is invalid (person: ' . $organizationMemberCreationRequest->getUsername() . ')');
|
|
|
|
|
|
|
+ $organizationMemberCreationRequest->getMobile() !== null
|
|
|
|
|
+ && !$this->phoneNumberUtil->isPossibleNumber($organizationMemberCreationRequest->getMobile())) {
|
|
|
|
|
+ throw new \RuntimeException('Mobile phone number is invalid (person: '.$organizationMemberCreationRequest->getUsername().')');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$phoneNumber = $this->phoneNumberUtil->parse($organizationMemberCreationRequest->getPhone());
|
|
$phoneNumber = $this->phoneNumberUtil->parse($organizationMemberCreationRequest->getPhone());
|