<?php
namespace App\EventSubscriber;
use App\Entity\ProcesVerval;
use App\Events\EnterpriseDataFetchedEvent;
use App\Service\DocumentGeneratorService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class DocumentGenerationSubscriber implements EventSubscriberInterface
{
private DocumentGeneratorService $documentGenerator;
public function __construct(DocumentGeneratorService $documentGenerator)
{
$this->documentGenerator = $documentGenerator;
}
public static function getSubscribedEvents(): array
{
return [
EnterpriseDataFetchedEvent::DOCUMENT_PV_EVENT => [
['prepareDocumentRegeneration', 110],
['createDocumentsDeclarationConfidentialite', 100],
['createDocumentsResultatAssembleGenerale', 90],
['createDocumentsPouvoir', 80],
['createDocumentsEnvoieMailAuClient', 70],
['createDocumentsFeuillePresenceAssembleGeneral', 60],
['createDocumentsTableauRecapulatif', 50],
['createDocumentAttestationConformite', 40],
['createDocumentDelegationPouvoirComptes', 30],
['createDocumentProcesVerbalAGO', 20],
['createDocumentNoteAudit', 19],
['createDocumentRapportGestion', 18],
['createDocumentRapportSpecialPresident', 17],
['createDocumentLettreAccompagnementApprobation', 16],
['createDocumentLettreGreffeDepotComptes', 15],
]
];
}
public function createDocumentsDeclarationConfidentialite(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_CONFIDENTIALITE);
}
public function createDocumentsResultatAssembleGenerale(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_RESULTAT_AG);
}
public function createDocumentsPouvoir(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_POUVOIR);
}
public function createDocumentsEnvoieMailAuClient(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_ENVOI_MAIL_CLIENT);
}
public function createDocumentsFeuillePresenceAssembleGeneral(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_PRESENCE_AG);
}
public function createDocumentsTableauRecapulatif(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_RECAPITULATIF);
}
public function createDocumentAttestationConformite(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_ACCEPTEMENT_CONFORMITE);
}
public function createDocumentDelegationPouvoirComptes(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_DELEGATION_POUVOIR_COMPTES);
}
public function createDocumentProcesVerbalAGO(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_PV_AGO);
}
public function createDocumentNoteAudit(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_NOTE_AUDIT);
}
public function createDocumentRapportGestion(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_RAPPORT_GESTION);
}
public function createDocumentRapportSpecialPresident(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_RAPPORT_SPECIAL_PRESIDENT);
}
public function createDocumentLettreAccompagnementApprobation(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_LETTRE_ACCOMPAGNEMENT_APPROBATION);
}
public function createDocumentLettreGreffeDepotComptes(GenericEvent $event): void
{
$this->generate($event, ProcesVerval::DOCUMENT_LETTRE_GREFFE_DEPOT_COMPTES);
}
public function prepareDocumentRegeneration(GenericEvent $event): void
{
$pv = $event->getSubject();
$this->documentGenerator->deleteExistingDocuments($pv);
}
private function generate(GenericEvent $event, string $documentType): void
{
$pv = $event->getSubject();
$this->documentGenerator->generateDocuments($pv, $documentType);
}
}