Commit 11ad207f authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Notification à l'issue de la validation de la PDC : ajout de la BU en copie du mail

parent 93d5a3ac
Loading
Loading
Loading
Loading
+2 −9
Changes for module/Application/src/Application/Controller/ValidationController.php: 2 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class ValidationController extends AbstractController
    use VariableServiceAwareTrait;
    use UtilisateurServiceAwareTrait;

    public function pageDeCouvertureAction()
    public function pageDeCouvertureAction(): ViewModel
    {
        $these = $this->requestedThese();
        $result = $this->confirm()->execute();
@@ -41,23 +41,16 @@ class ValidationController extends AbstractController

        // si un tableau est retourné par le plugin, l'opération a été confirmée
        if (is_array($result)) {
            $notification = new ValidationPageDeCouvertureNotification();
            $notification->setThese($these);
            $notification->setAction($action);

            if ($action === 'valider') {
                $this->validationService->validatePageDeCouverture($these);
                $successMessage = "Validation de la page de couverture enregistrée avec succès.";

                // notification
                $this->notifierService->trigger($notification);
                $this->notifierService->triggerValidationPageDeCouvertureNotification($these, $action);
            }
            elseif ($action === 'devalider') {
                $this->validationService->unvalidatePageDeCouverture($these);
                $successMessage ="Validation de la page de couverture annulée avec succès.";

                // notification
//                $this->notifierService->trigger($notification);
            }
            else {
                throw new RuntimeException("Action inattendue!");
+29 −6
Changes for module/Application/src/Application/Notification/ValidationPageDeCouvertureNotification.php: 29 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -18,11 +18,27 @@ class ValidationPageDeCouvertureNotification extends Notification

    private $action;

    /**
     * @var string
     */
    private $emailBu;

    /**
     * @param string $emailBu
     * @return self
     */
    public function setEmailBu(string $emailBu): self
    {
        $this->emailBu = $emailBu;

        return $this;
    }

    /**
     * @param string $action
     * @return self
     */
    public function setAction($action)
    public function setAction(string $action): self
    {
        if (!in_array($action, $actions = [self::ACTION_VALIDER, self::ACTION_DEVALIDER])) {
            throw new LogicException(sprintf(
@@ -38,19 +54,26 @@ class ValidationPageDeCouvertureNotification extends Notification
    }

    /**
     * @return static
     * @return self
     */
    public function prepare()
    public function prepare(): self
    {
        /** @var Individu[] $individusSansMail */
        $individusSansMail = [];
        $emailsDirecteurs = $this->these->getDirecteursTheseEmails($individusSansMail);

        $to = $this->these->getDoctorant()->getEmail();
        $cc = $this->these->getDirecteursTheseEmails($individusSansMail);
        $cc = array_merge(
            $emailsDirecteurs,
            [$this->emailBu => $this->emailBu]
        );

        $infoMessage = sprintf(
            "Un mail de notification vient d'être envoyé au doctorant avec le(s) directeur(s) de thèse en copie (%s)",
            "Un mail de notification vient d'être envoyé au doctorant (%s), avec copie à la direction de thèse (%s) " .
            "et à %s",
            $to,
            implode(',', $cc)
            implode(',', $emailsDirecteurs),
            $this->emailBu
        );

        $errorMessage = null;
+19 −1
Changes for module/Application/src/Application/Service/Notification/NotifierService.php: 19 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -10,10 +10,11 @@ use Application\Entity\Db\These;
use Application\Entity\Db\Utilisateur;
use Application\Entity\Db\Variable;
use Application\Notification\ChangementCorrectionAttendueNotification;
use Application\Notification\ChangementsResultatsThesesNotification;
use Application\Notification\PasDeMailPresidentJury;
use Application\Notification\ResultatTheseAdmisNotification;
use Application\Notification\ChangementsResultatsThesesNotification;
use Application\Notification\ValidationDepotTheseCorrigeeNotification;
use Application\Notification\ValidationPageDeCouvertureNotification;
use Application\Notification\ValidationRdvBuNotification;
use Application\Rule\NotificationDepotVersionCorrigeeAttenduRule;
use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait;
@@ -47,6 +48,23 @@ class NotifierService extends \Notification\Service\NotifierService
     */
    protected $urlHelper;

    /**
     * Notification à l'issue de la validation de la page de couverture.
     *
     * @param \Application\Entity\Db\These $these
     * @param string $action
     * @throws \Notification\Exception\NotificationException
     */
    public function triggerValidationPageDeCouvertureNotification(These $these, string $action)
    {
        $notification = new ValidationPageDeCouvertureNotification();
        $notification->setThese($these);
        $notification->setAction($action);
        $notification->setEmailBu($this->fetchEmailBu($these));

        $this->trigger($notification);
    }

    /**
     * Notification concernant la validation à l'issue du RDV BU.
     *