Commit 44aa42fc authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix notification (a revoir)

parent ac5f72cc
Loading
Loading
Loading
Loading
Loading
+25 −4
Changes for src/Service/SignatureService.php: 25 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -759,6 +759,8 @@ class SignatureService
    {
        $this->getLoggerService()->info("Envoi de '$signature'");
        if ($signature->isSendable()) {
            $send = false;

            try {
                $this->getLetterfileService()->getLetterFileStrategy(
                    $signature->getLetterfileKey()
@@ -777,14 +779,26 @@ class SignatureService
                        ->setDateUpdate(new \DateTime());
                }
                $this->getObjectManager()->flush();
                $this->notifications($signature);
                $this->triggerSignatureEvent($signature, SignatureEvent::EVENT_TYPE_SEND);
                $send = true;
            } catch (Exception $exception) {
                $this->getLoggerService()->critical("Can't save Signature, DB error : " . $exception->getMessage());
                $this->getLoggerService()->critical("Can't save Signature, DB error : " . $exception->getMessage() . " - " . $exception->getTraceAsString());
                throw new SignatureException(
                    "La demande a été envoyé mais un problème est survenu lors de l'enregistrement"
                );
            }
            if( $send ){
                try {
                    $this->triggerSignatureEvent($signature, SignatureEvent::EVENT_TYPE_SEND);
                } catch (Exception $e) {
                    $this->getLoggerService()->critical("Impossible de déclencher la signature : " . $e->getMessage());
                }

                try {
                    $this->notifications($signature);
                } catch (Exception $e) {
                    $this->getLoggerService()->error("Impossible de notifier les intervenants : " . $e->getMessage());
                }
            }
        }
        else {
            throw new SignatureException("La demande '" . $signature->getId() . "' ne peut pas être envoyée");
@@ -852,6 +866,8 @@ class SignatureService
                $type = "visa";
            }

            $this->getLoggerService()->debug("LETTERFILE: " . $signature->getLetterfileKey());

            $messageSubject = $this->getSignatureConfigurationService()->getNotificationsSubject();
            $messageBody = $this->getSignatureConfigurationService()->getNotificationsBody();

@@ -863,7 +879,7 @@ class SignatureService

                    $datas = [];

                    if ($action == 'viser') {
                    if ($action == 'viser' && $signature->getLetterfileKey() == 'internal') {
                        // TODO Pose problème !!!
                        $link = $baseUrl . $urlBuilder(
                                'unicaen-signature/internal/visa',
@@ -900,8 +916,13 @@ class SignatureService

    public function notifications(Signature $signature): void
    {
        try {
            $this->notificationsRecipients($signature);
            $this->notificationsObservers($signature);
        } catch (Exception $e) {
            $this->getLoggerService()->error("NOTIFICATION ERROR : " . $e->getMessage());
            $this->getLoggerService()->error($e->getTraceAsString());
        }
//        $this->getLoggerService()->info("notifications($signature)");
//        if ($signature->isNotifiable()) {
//            $notificationsCaller = $this->getSignatureConfigurationService()->getNotificationsCaller();