|
|
@@ -21,7 +21,6 @@ use App\Enum\Education\CycleEnum;
|
|
|
use App\Enum\Organization\AddressPostalOrganizationTypeEnum;
|
|
|
use App\Enum\Person\AddressPostalPersonTypeEnum;
|
|
|
use App\Repository\Core\CountryRepository;
|
|
|
-use App\Repository\Network\NetworkRepository;
|
|
|
use App\Repository\Organization\OrganizationRepository;
|
|
|
use App\Repository\Person\PersonRepository;
|
|
|
use App\Service\Dolibarr\DolibarrApiService;
|
|
|
@@ -39,6 +38,7 @@ use Symfony\Component\String\ByteString;
|
|
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
|
|
use Symfony\Contracts\Service\Attribute\Required;
|
|
|
use Throwable;
|
|
|
+use App\Service\Organization\Utils as OrganizationUtils;
|
|
|
|
|
|
class OrganizationFactory
|
|
|
{
|
|
|
@@ -48,7 +48,7 @@ class OrganizationFactory
|
|
|
private readonly SubdomainService $subdomainService,
|
|
|
private readonly OrganizationRepository $organizationRepository,
|
|
|
private readonly CountryRepository $countryRepository,
|
|
|
- private readonly NetworkRepository $networkRepository,
|
|
|
+ private readonly OrganizationUtils $organizationUtils,
|
|
|
private readonly Typo3Service $typo3Service,
|
|
|
private readonly DolibarrApiService $dolibarrApiService,
|
|
|
private readonly EntityManagerInterface $entityManager,
|
|
|
@@ -354,11 +354,13 @@ class OrganizationFactory
|
|
|
throw new \RuntimeException('No parent organization found for id ' . $organizationCreationRequest->getParentId());
|
|
|
}
|
|
|
|
|
|
- $network = $this->networkRepository->find($organizationCreationRequest->getNetworkId());
|
|
|
- if (!$network) {
|
|
|
- throw new \RuntimeException('No network found for id ' . $organizationCreationRequest->getNetworkId());
|
|
|
+ $networkOrganization = $this->organizationUtils->getActiveNetworkOrganization($parent);
|
|
|
+ if (!$networkOrganization) {
|
|
|
+ throw new \RuntimeException('No network found for parent ' . $organizationCreationRequest->getParentId());
|
|
|
}
|
|
|
|
|
|
+ $network = $networkOrganization->getNetwork();
|
|
|
+
|
|
|
$networkOrganization = new NetworkOrganization();
|
|
|
$networkOrganization->setParent($parent);
|
|
|
$networkOrganization->setNetwork($network);
|