|
|
@@ -19,7 +19,8 @@ class SubdomainDataPersister extends BaseDataPersister
|
|
|
private Typo3Service $typo3Service,
|
|
|
private BindFileService $bindFileService
|
|
|
)
|
|
|
- {}
|
|
|
+ {
|
|
|
+ }
|
|
|
|
|
|
public function supports($data, array $context = []): bool
|
|
|
{
|
|
|
@@ -41,14 +42,18 @@ class SubdomainDataPersister extends BaseDataPersister
|
|
|
|
|
|
/**
|
|
|
* @param Subdomain $subdomain
|
|
|
+ * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
|
|
|
*/
|
|
|
protected function postPersist($subdomain): void
|
|
|
{
|
|
|
+ $shallPersist = false;
|
|
|
+
|
|
|
// Ensure it is the only active subdomain of this organization
|
|
|
if ($subdomain->isActive()) {
|
|
|
foreach ($subdomain->getOrganization()->getSubdomains() as $other) {
|
|
|
- if ($other !== $subdomain) {
|
|
|
+ if ($other !== $subdomain && $other->isActive()) {
|
|
|
$other->setActive(false);
|
|
|
+ $shallPersist = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -58,18 +63,23 @@ class SubdomainDataPersister extends BaseDataPersister
|
|
|
$this->bindFileService->registerSubdomain($subdomain->getSubdomain());
|
|
|
}
|
|
|
|
|
|
- if ($this->isPutRequest()) {
|
|
|
- // Update the typo3 website
|
|
|
- if (
|
|
|
- $this->previousData() &&
|
|
|
- $subdomain->isActive() && !$this->previousData()->isActive()
|
|
|
- ) {
|
|
|
- $this->typo3Service->updateSite($subdomain->getOrganization()->getId());
|
|
|
+ // Update the admin username
|
|
|
+ if ($this->isPutRequest() && $this->previousData()) {
|
|
|
+ if ($subdomain->isActive() && !$this->previousData()->isActive()) {
|
|
|
+ Utils::updateAdminUsername($subdomain->getOrganization());
|
|
|
+ $shallPersist = true;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // update the admin username
|
|
|
- if ($subdomain->isActive()) {
|
|
|
- Utils::updateAdminUsername($subdomain->getOrganization());
|
|
|
+ if ($shallPersist) {
|
|
|
+ $this->entityManager->flush();
|
|
|
+ }
|
|
|
+
|
|
|
+ // Update the typo3 website
|
|
|
+ // /!\ This has to be executed after everything has been persisted
|
|
|
+ if ($this->isPutRequest() && $this->previousData()) {
|
|
|
+ if ($subdomain->isActive() && !$this->previousData()->isActive()) {
|
|
|
+ $this->typo3Service->updateSite($subdomain->getOrganization()->getId());
|
|
|
}
|
|
|
}
|
|
|
}
|