|
@@ -6,9 +6,10 @@ namespace App\DataPersister\Organization;
|
|
|
use App\DataPersister\BaseDataPersister;
|
|
use App\DataPersister\BaseDataPersister;
|
|
|
use App\Entity\Organization\Subdomain;
|
|
use App\Entity\Organization\Subdomain;
|
|
|
use App\Message\Command\Typo3\Typo3UpdateCommand;
|
|
use App\Message\Command\Typo3\Typo3UpdateCommand;
|
|
|
|
|
+use App\Service\MailHub;
|
|
|
|
|
+use App\Service\OnChange\Organization\OnSubdomainChange;
|
|
|
use App\Service\Organization\Utils;
|
|
use App\Service\Organization\Utils;
|
|
|
use App\Service\Typo3\BindFileService;
|
|
use App\Service\Typo3\BindFileService;
|
|
|
-use Exception;
|
|
|
|
|
use Symfony\Component\Messenger\MessageBusInterface;
|
|
use Symfony\Component\Messenger\MessageBusInterface;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -19,6 +20,7 @@ class SubdomainDataPersister extends BaseDataPersister
|
|
|
public function __construct(
|
|
public function __construct(
|
|
|
private BindFileService $bindFileService,
|
|
private BindFileService $bindFileService,
|
|
|
private MessageBusInterface $messageBus,
|
|
private MessageBusInterface $messageBus,
|
|
|
|
|
+ private OnSubdomainChange $onSubdomainChange
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
public function supports($data, array $context = []): bool
|
|
public function supports($data, array $context = []): bool
|
|
@@ -42,7 +44,7 @@ class SubdomainDataPersister extends BaseDataPersister
|
|
|
{
|
|
{
|
|
|
$shallPersist = false;
|
|
$shallPersist = false;
|
|
|
|
|
|
|
|
- // Ensure it is the only active subdomain of this organization
|
|
|
|
|
|
|
+ // Ensure it is the only active subdomain of this organization by disabling other organization subdomains
|
|
|
if ($subdomain->isActive()) {
|
|
if ($subdomain->isActive()) {
|
|
|
foreach ($subdomain->getOrganization()->getSubdomains() as $other) {
|
|
foreach ($subdomain->getOrganization()->getSubdomains() as $other) {
|
|
|
if ($other !== $subdomain && $other->isActive()) {
|
|
if ($other !== $subdomain && $other->isActive()) {
|
|
@@ -60,7 +62,7 @@ class SubdomainDataPersister extends BaseDataPersister
|
|
|
// Update the admin username
|
|
// Update the admin username
|
|
|
if ($this->isPutRequest() && $this->previousData()) {
|
|
if ($this->isPutRequest() && $this->previousData()) {
|
|
|
if ($subdomain->isActive() && !$this->previousData()->isActive()) {
|
|
if ($subdomain->isActive() && !$this->previousData()->isActive()) {
|
|
|
- Utils::updateAdminUsername($subdomain->getOrganization());
|
|
|
|
|
|
|
+ $this->onSubdomainChange->updateAdminUsername($subdomain->getOrganization());
|
|
|
$shallPersist = true;
|
|
$shallPersist = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -78,5 +80,12 @@ class SubdomainDataPersister extends BaseDataPersister
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // Envoi d'un email
|
|
|
|
|
+ if ($this->isPutRequest() && $this->previousData()) {
|
|
|
|
|
+ if ($subdomain->isActive() && !$this->previousData()->isActive()) {
|
|
|
|
|
+ $this->onSubdomainChange->sendEmailAfterSubdomainChange($subdomain);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|