|
|
@@ -11,6 +11,7 @@ use App\Repository\Access\AccessRepository;
|
|
|
use App\Repository\Organization\SubdomainRepository;
|
|
|
use App\Service\Mailer\Model\SubdomainChangeModel;
|
|
|
use App\Service\Organization\Utils as OrganizationUtils;
|
|
|
+use Doctrine\DBAL\Connection;
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
use Symfony\Bundle\SecurityBundle\Security;
|
|
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
|
|
@@ -149,7 +150,10 @@ class SubdomainService
|
|
|
* @return Subdomain
|
|
|
*/
|
|
|
public function activateSubdomain(Subdomain $subdomain): Subdomain {
|
|
|
- if ($subdomain->isActive()) {
|
|
|
+
|
|
|
+ $currentActiveSubdomain = $this->subdomainRepository->getActiveSubdomainOf($subdomain->getOrganization());
|
|
|
+
|
|
|
+ if ($currentActiveSubdomain && $subdomain->getId() === $currentActiveSubdomain->getId()) {
|
|
|
throw new \RuntimeException('The subdomain is already active');
|
|
|
}
|
|
|
if (!$subdomain->getId()) {
|
|
|
@@ -169,6 +173,7 @@ class SubdomainService
|
|
|
return $subdomain;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* The subdomain becomes the only active subdomain of its organization.
|
|
|
* New state is persisted is database.
|