|
|
@@ -6,6 +6,9 @@ namespace App\DataPersister\Organization;
|
|
|
use App\DataPersister\BaseDataPersister;
|
|
|
use App\Entity\Organization\Parameters;
|
|
|
use App\Message\Command\Parameters\AverageChange;
|
|
|
+use App\Message\Command\Typo3\Typo3DeleteCommand;
|
|
|
+use App\Message\Command\Typo3\Typo3UndeleteCommand;
|
|
|
+use App\Message\Command\Typo3\Typo3UpdateCommand;
|
|
|
use App\Service\OnChange\Organization\OnParametersChange;
|
|
|
use App\Service\Typo3\Typo3Service;
|
|
|
use Exception;
|
|
|
@@ -19,7 +22,9 @@ class ParametersDataPersister extends BaseDataPersister
|
|
|
public function __construct(
|
|
|
private MessageBusInterface $messageBus,
|
|
|
private OnParametersChange $onParametersChange,
|
|
|
- private Typo3Service $typo3Service
|
|
|
+ private Typo3Service $typo3Service,
|
|
|
+ private \App\Service\Network\Utils $networkUtils
|
|
|
+
|
|
|
)
|
|
|
{}
|
|
|
|
|
|
@@ -50,6 +55,14 @@ class ParametersDataPersister extends BaseDataPersister
|
|
|
$this->previousData()->getMusicalDate()
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ // Une structure CMF n'a pas le droit de désactiver son site typo3
|
|
|
+ if (
|
|
|
+ $parameters->getDesactivateOpentalentSiteWeb() === true &&
|
|
|
+ $this->networkUtils->isCMFAndActiveNow($parameters->getOrganization())
|
|
|
+ ) {
|
|
|
+ throw new \RuntimeException('This structure is currently active in the CMF network, the website can not be disabled.');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -59,20 +72,22 @@ class ParametersDataPersister extends BaseDataPersister
|
|
|
//La note maximale du suivi pédagogique change
|
|
|
if(
|
|
|
$this->previousData() &&
|
|
|
- $this->previousData()->getAverage() != $parameters->getAverage()
|
|
|
+ $this->previousData()->getAverage() !== $parameters->getAverage()
|
|
|
){
|
|
|
$this->messageBus->dispatch(
|
|
|
new AverageChange($parameters->getId())
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- // Le custom domain a été modifié
|
|
|
+ // Le customDomain a été modifié, on met à jour le site typo3 (s'il est actif)
|
|
|
if(
|
|
|
$this->previousData() &&
|
|
|
!$parameters->getDesactivateOpentalentSiteWeb() &&
|
|
|
$this->previousData()->getCustomDomain() !== $parameters->getCustomDomain()
|
|
|
){
|
|
|
- $this->typo3Service->updateSite($parameters->getOrganization()->getId());
|
|
|
+ $this->messageBus->dispatch(
|
|
|
+ new Typo3UpdateCommand($parameters->getOrganization()->getId())
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
// Le site web opentalent a été désactivé / réactivé
|
|
|
@@ -81,10 +96,16 @@ class ParametersDataPersister extends BaseDataPersister
|
|
|
$this->previousData()->getDesactivateOpentalentSiteWeb() !== $parameters->getDesactivateOpentalentSiteWeb()
|
|
|
){
|
|
|
if ($parameters->getDesactivateOpentalentSiteWeb()) {
|
|
|
- $this->typo3Service->deleteSite($parameters->getOrganization()->getId());
|
|
|
+ $this->messageBus->dispatch(
|
|
|
+ new Typo3DeleteCommand($parameters->getOrganization()->getId())
|
|
|
+ );
|
|
|
} else {
|
|
|
- $this->typo3Service->undeleteSite($parameters->getOrganization()->getId());
|
|
|
- $this->typo3Service->updateSite($parameters->getOrganization()->getId());
|
|
|
+ $this->messageBus->dispatch(
|
|
|
+ new Typo3UndeleteCommand($parameters->getOrganization()->getId())
|
|
|
+ );
|
|
|
+ $this->messageBus->dispatch(
|
|
|
+ new Typo3UpdateCommand($parameters->getOrganization()->getId())
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
}
|