|
@@ -10,7 +10,6 @@ use App\Service\OnChange\OnChangeContext;
|
|
|
use App\Service\OnChange\OnChangeDefault;
|
|
use App\Service\OnChange\OnChangeDefault;
|
|
|
use App\Service\Organization\Utils as OrganizationUtils;
|
|
use App\Service\Organization\Utils as OrganizationUtils;
|
|
|
use App\Service\Typo3\BindFileService;
|
|
use App\Service\Typo3\BindFileService;
|
|
|
-use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
use Symfony\Component\Messenger\MessageBusInterface;
|
|
use Symfony\Component\Messenger\MessageBusInterface;
|
|
|
|
|
|
|
|
class OnSubdomainChange extends OnChangeDefault
|
|
class OnSubdomainChange extends OnChangeDefault
|
|
@@ -20,10 +19,10 @@ class OnSubdomainChange extends OnChangeDefault
|
|
|
private AccessUtils $accessUtils,
|
|
private AccessUtils $accessUtils,
|
|
|
private MailHub $mailHub,
|
|
private MailHub $mailHub,
|
|
|
private BindFileService $bindFileService,
|
|
private BindFileService $bindFileService,
|
|
|
- private MessageBusInterface $messageBus,
|
|
|
|
|
- private EntityManagerInterface $entityManager
|
|
|
|
|
|
|
+ private MessageBusInterface $messageBus
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
|
|
+ /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
|
|
|
public function validate($subdomain, OnChangeContext $context): void {
|
|
public function validate($subdomain, OnChangeContext $context): void {
|
|
|
// Ensure we do not exceed the limit of 3 subdomains per organization
|
|
// Ensure we do not exceed the limit of 3 subdomains per organization
|
|
|
if (
|
|
if (
|
|
@@ -34,28 +33,27 @@ class OnSubdomainChange extends OnChangeDefault
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function onChange($subdomain, OnChangeContext $context): void {
|
|
|
|
|
- $shallPersist = false;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
|
|
|
|
|
+ public function beforeChange($subdomain, OnChangeContext $context): void
|
|
|
|
|
+ {
|
|
|
// Ensure it is the only active subdomain of this organization by disabling other organization subdomains
|
|
// 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()) {
|
|
|
$other->setActive(false);
|
|
$other->setActive(false);
|
|
|
- $shallPersist = true;
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** @noinspection PhpParameterNameChangedDuringInheritanceInspection */
|
|
|
|
|
+ public function onChange($subdomain, OnChangeContext $context): void {
|
|
|
|
|
|
|
|
// Register into the BindFile
|
|
// Register into the BindFile
|
|
|
if ($context->isPostRequest()) {
|
|
if ($context->isPostRequest()) {
|
|
|
$this->bindFileService->registerSubdomain($subdomain->getSubdomain());
|
|
$this->bindFileService->registerSubdomain($subdomain->getSubdomain());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ($shallPersist) {
|
|
|
|
|
- $this->entityManager->flush();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// A new subdomain is active
|
|
// A new subdomain is active
|
|
|
// /!\ This has to be executed after everything has been persisted
|
|
// /!\ This has to be executed after everything has been persisted
|
|
|
if ($subdomain->isActive() && !($context->previousData() && $context->previousData()->isActive())) {
|
|
if ($subdomain->isActive() && !($context->previousData() && $context->previousData()->isActive())) {
|