From 5f58f3d63321e3fe306a000ef3b0c61c7442ab96 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Metivier <jean-philippe.metivier@unicaen.fr> Date: Fri, 29 Nov 2024 14:10:28 +0100 Subject: [PATCH] Fiabilisation de code --- .../Helper/AgentAffectationViewHelper.php | 7 +- .../src/View/Helper/AgentStatutViewHelper.php | 7 +- .../Form/AutocompleteAwareTrait.php | 10 +-- .../View/Helper/AgentViewHelper.php | 4 +- .../Controller/DemandeExterneController.php | 6 +- .../Fichier/src/Fichier/Entity/Db/Fichier.php | 86 ++++-------------- .../Fichier/src/Fichier/Entity/Db/Nature.php | 41 ++------- .../Controller/AbonnementController.php | 2 +- .../Controller/InscriptionController.php | 2 +- .../Controller/SessionParametreController.php | 2 +- .../view/formation/default/confirmation.phtml | 87 ------------------- .../view/formation/default/default-form.phtml | 53 ----------- .../view/formation/default/probleme.phtml | 15 ---- .../view/formation/default/reponse.phtml | 8 -- 14 files changed, 38 insertions(+), 292 deletions(-) delete mode 100644 module/Formation/view/formation/default/confirmation.phtml delete mode 100644 module/Formation/view/formation/default/default-form.phtml delete mode 100644 module/Formation/view/formation/default/probleme.phtml delete mode 100644 module/Formation/view/formation/default/reponse.phtml diff --git a/module/Agent/src/View/Helper/AgentAffectationViewHelper.php b/module/Agent/src/View/Helper/AgentAffectationViewHelper.php index 4f8990e3..02e8c9b9 100644 --- a/module/Agent/src/View/Helper/AgentAffectationViewHelper.php +++ b/module/Agent/src/View/Helper/AgentAffectationViewHelper.php @@ -20,12 +20,7 @@ use Laminas\View\Resolver\TemplatePathStack; */ class AgentAffectationViewHelper extends AbstractHelper { - /** - * @param AgentAffectation $affectation - * @param array $options - * @return string|Partial - */ - public function __invoke($affectation, $options = []) + public function __invoke(AgentAffectation $affectation, array $options = []): string|Partial { /** @var PhpRenderer $view */ $view = $this->getView(); diff --git a/module/Agent/src/View/Helper/AgentStatutViewHelper.php b/module/Agent/src/View/Helper/AgentStatutViewHelper.php index 3b728cc3..a86028ef 100644 --- a/module/Agent/src/View/Helper/AgentStatutViewHelper.php +++ b/module/Agent/src/View/Helper/AgentStatutViewHelper.php @@ -21,12 +21,7 @@ use Laminas\View\Resolver\TemplatePathStack; */ class AgentStatutViewHelper extends AbstractHelper { - /** - * @param AgentStatut $statut - * @param array $options - * @return string|Partial - */ - public function __invoke($statut, $options = []) + public function __invoke(AgentStatut $statut, array $options = []): string|Partial { /** @var PhpRenderer $view */ $view = $this->getView(); diff --git a/module/Application/src/Application/Form/AutocompleteAwareTrait.php b/module/Application/src/Application/Form/AutocompleteAwareTrait.php index 454e2602..e2adaf98 100644 --- a/module/Application/src/Application/Form/AutocompleteAwareTrait.php +++ b/module/Application/src/Application/Form/AutocompleteAwareTrait.php @@ -6,18 +6,12 @@ trait AutocompleteAwareTrait { private $autocomplete; - /** - * @return mixed - */ - public function getAutocomplete() + public function getAutocomplete(): mixed { return $this->autocomplete; } - /** - * @param mixed $autocomplete - */ - public function setAutocomplete($autocomplete) + public function setAutocomplete(mixed $autocomplete): void { $this->autocomplete = $autocomplete; } diff --git a/module/Application/src/Application/View/Helper/AgentViewHelper.php b/module/Application/src/Application/View/Helper/AgentViewHelper.php index 8e937556..ce912076 100644 --- a/module/Application/src/Application/View/Helper/AgentViewHelper.php +++ b/module/Application/src/Application/View/Helper/AgentViewHelper.php @@ -3,7 +3,6 @@ namespace Application\View\Helper; use Agent\Entity\Db\Agent; -use Application\View\Renderer\PhpRenderer; use Laminas\View\Helper\AbstractHelper; use Laminas\View\Helper\Partial; use Laminas\View\Resolver\TemplatePathStack; @@ -17,9 +16,8 @@ class AgentViewHelper extends AbstractHelper * @param array $options * @return string|Partial */ - public function __invoke($agent, $mode = 'affichage', $options = []) + public function __invoke(Agent $agent, string $mode = 'affichage', array $options = []): string|Partial { - /** @var PhpRenderer $view */ $view = $this->getView(); $view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]])); diff --git a/module/DemandeExterne/src/Controller/DemandeExterneController.php b/module/DemandeExterne/src/Controller/DemandeExterneController.php index 4bd81db7..b1aa2709 100644 --- a/module/DemandeExterne/src/Controller/DemandeExterneController.php +++ b/module/DemandeExterne/src/Controller/DemandeExterneController.php @@ -593,7 +593,7 @@ class DemandeExterneController extends AbstractActionController 'title' => "Transformation de la demande en formation", 'form' => $form, ]); - $vm->setTemplate('formation/default/default-form'); + $vm->setTemplate('default/default-form'); return $vm; } @@ -635,7 +635,7 @@ class DemandeExterneController extends AbstractActionController } $vm = new ViewModel(); - $vm->setTemplate('formation/default/default-form'); + $vm->setTemplate('default/default-form'); $vm->setVariables([ 'title' => "Téléverserment d'un devis pour la formation", 'form' => $form, @@ -679,7 +679,7 @@ class DemandeExterneController extends AbstractActionController } $vm = new ViewModel(); - $vm->setTemplate('formation/default/default-form'); + $vm->setTemplate('default/default-form'); $vm->setVariables([ 'title' => 'Téléverserment du programme de la formation', 'form' => $form, diff --git a/module/Fichier/src/Fichier/Entity/Db/Fichier.php b/module/Fichier/src/Fichier/Entity/Db/Fichier.php index 78a28387..2dd7d66e 100644 --- a/module/Fichier/src/Fichier/Entity/Db/Fichier.php +++ b/module/Fichier/src/Fichier/Entity/Db/Fichier.php @@ -9,122 +9,74 @@ use UnicaenUtilisateur\Entity\Db\HistoriqueAwareTrait; class Fichier implements HistoriqueAwareInterface { use HistoriqueAwareTrait; - /** @var string */ - private $id; - /** @var string */ - private $nomOriginal; - /** @var string */ - private $nomStockage; - /** @var Nature */ - private $nature; - /** @var string */ - private $typeMime; - /** @var string */ - private $taille; - - /** - * @return string - */ - public function getId() + private ?string $id = null; + private ?string $nomOriginal = null; + private ?string $nomStockage = null; + private ?Nature $nature = null; + private ?string $typeMime = null; + private ?string $taille = null; + + public function getId(): ?string { return $this->id; } - /** - * @param string $id - * @return Fichier - */ - public function setId($id) + public function setId(string $id): Fichier { $this->id = $id; return $this; } - /** - * @return string - */ - public function getNomOriginal() + public function getNomOriginal(): ?string { return $this->nomOriginal; } - /** - * @param string $nomOriginal - * @return Fichier - */ - public function setNomOriginal($nomOriginal) + public function setNomOriginal(string $nomOriginal): Fichier { $this->nomOriginal = $nomOriginal; return $this; } - /** - * @return string - */ - public function getNomStockage() + public function getNomStockage(): ?string { return $this->nomStockage; } - /** - * @param string $nomStockage - * @return Fichier - */ - public function setNomStockage($nomStockage) + public function setNomStockage(string $nomStockage): Fichier { $this->nomStockage = $nomStockage; return $this; } - /** - * @return Nature - */ - public function getNature() + public function getNature(): ?Nature { return $this->nature; } - /** - * @param Nature $nature - * @return Fichier - */ - public function setNature($nature) + public function setNature(Nature $nature): Fichier { $this->nature = $nature; return $this; } - /** - * @return string - */ - public function getTypeMime() + public function getTypeMime(): ?string { return $this->typeMime; } - /** - * @param string $typeMime - * @return Fichier - */ - public function setTypeMime($typeMime) + public function setTypeMime(string $typeMime): Fichier { $this->typeMime = $typeMime; return $this; } - /** - * @return string - */ - public function getTaille() + public function getTaille(): ?string { return $this->taille; } - /** - * @param string $taille - * @return Fichier - */ - public function setTaille($taille) + public function setTaille(string $taille): Fichier { $this->taille = $taille; return $this; diff --git a/module/Fichier/src/Fichier/Entity/Db/Nature.php b/module/Fichier/src/Fichier/Entity/Db/Nature.php index 45cbb22f..3078cd87 100644 --- a/module/Fichier/src/Fichier/Entity/Db/Nature.php +++ b/module/Fichier/src/Fichier/Entity/Db/Nature.php @@ -8,57 +8,32 @@ use Application\Entity\Db\Traits\HasDescriptionTrait; class Nature implements HasDescriptionInterface { use HasDescriptionTrait; - const CV = 'CV'; - const MOTIV = 'MOTIV'; - const FORMATION = 'FORMATION'; - const AUTRE = 'AUTRE'; + private ?int $id = null; + private ?string $code = null; + private ?string $libelle = null; - /** @var integer */ - private $id; - /** @var string */ - private $code; - /** @var string */ - private $libelle; - - /** - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } - /** - * @return string - */ - public function getCode() + public function getCode(): ?string { return $this->code; } - /** - * @param string $code - * @return Nature - */ - public function setCode($code) + public function setCode(?string $code): Nature { $this->code = $code; return $this; } - /** - * @return string - */ - public function getLibelle() + public function getLibelle(): ?string { return $this->libelle; } - /** - * @param string $libelle - * @return Nature - */ - public function setLibelle($libelle) + public function setLibelle(?string $libelle): Nature { $this->libelle = $libelle; return $this; diff --git a/module/Formation/src/Formation/Controller/AbonnementController.php b/module/Formation/src/Formation/Controller/AbonnementController.php index 3365c2e0..583ad7b8 100644 --- a/module/Formation/src/Formation/Controller/AbonnementController.php +++ b/module/Formation/src/Formation/Controller/AbonnementController.php @@ -46,7 +46,7 @@ class AbonnementController extends AbstractActionController 'title' => "Ajouter un abonnement à un agent", 'form' => $form, ]); - $vm->setTemplate('formation/default/default-form'); + $vm->setTemplate('default/default-form'); return $vm; } diff --git a/module/Formation/src/Formation/Controller/InscriptionController.php b/module/Formation/src/Formation/Controller/InscriptionController.php index a59e1de5..8b028e96 100644 --- a/module/Formation/src/Formation/Controller/InscriptionController.php +++ b/module/Formation/src/Formation/Controller/InscriptionController.php @@ -549,7 +549,7 @@ class InscriptionController extends AbstractActionController } $vm = new ViewModel(); - $vm->setTemplate('formation/default/default-form'); + $vm->setTemplate('default/default-form'); $vm->setVariables([ 'title' => 'Téléverserment d\'un fichier', 'form' => $form, diff --git a/module/Formation/src/Formation/Controller/SessionParametreController.php b/module/Formation/src/Formation/Controller/SessionParametreController.php index de2141c5..1dcf4caa 100644 --- a/module/Formation/src/Formation/Controller/SessionParametreController.php +++ b/module/Formation/src/Formation/Controller/SessionParametreController.php @@ -44,7 +44,7 @@ class SessionParametreController extends AbstractActionController 'title' => "Paramètre de la session de formation", 'form' => $form, ]); - $vm->setTemplate('formation/default/default-form'); + $vm->setTemplate('default/default-form'); return $vm; } } \ No newline at end of file diff --git a/module/Formation/view/formation/default/confirmation.phtml b/module/Formation/view/formation/default/confirmation.phtml deleted file mode 100644 index fee475be..00000000 --- a/module/Formation/view/formation/default/confirmation.phtml +++ /dev/null @@ -1,87 +0,0 @@ -<?php - -/** - * @var string $title - * @var string $text - * @var string $action - * @var bool $complement - */ - -?> - -<p class="lead"> -<?php echo $text; ?> -</p> - -<div class="row"> - <div class="col-md-4"> - <form method="post" action="<?php echo $action; ?>"> -<table> - <tr><td> - <input type="hidden" name="reponse" value="oui"> - <input type="submit" name="oui" class="btn btn-success action" value="Oui, je suis sûr·e"> - <?php if ($complement === 'oui') : ?> - </td><td> - <label for="complement">Compléments liés à l'acceptation</label> - <textarea id="complement" name="complement" class="type2 form-control" style="width: 100%;"></textarea> - <?php endif; ?> - - </td></tr> -</table> -</form> - </div> - <div class="col-md-4"> - <form method="post" action="<?php echo $action; ?>"> -<table> - <tr><td> - <input type="hidden" name="reponse" value="non"> - <input type="submit" id="non" name="non" class="btn btn-danger action" value="Non, je ne veux pas"> - <?php if ($complement === 'non') : ?> - </td><td> - <label for="complement">Compléments liés au refus</label> - <textarea id="complement" name="complement" class="type2 form-control" style="width: 100%;"></textarea> - <?php endif; ?> - - </td></tr> -</table> -</form> - </div> -</div> - -<?php if ($complement !== true) : ?> - <script> - $(function() { - $("input#non").click(function(e){ - $('div.modal').modal('hide'); - e.preventDefault(); - }); - }); - </script> -<?php else : ?> - <script> - $(document).ready(function() { - tinymce.remove(); - tinymce.init({ - selector: '.tinymce', - toolbar: 'newdocument undo redo | bold italic underline removeformat | bullist', - resize: true, - language: 'fr_FR', - plugins: 'lists', - statusbar: true, - browser_spellcheck : true, - branding: false, - menu: {}, - body_id: 'complement', - setup: function (editor) { - editor.on("focusout", function () { - console.log(tinymce.get('complement').getContent()); - $('textarea').val(tinymce.get('complement').getContent()); - }); - } - }); - }); - - $('select').selectpicker(); - </script> -<?php endif; ?> - diff --git a/module/Formation/view/formation/default/default-form.phtml b/module/Formation/view/formation/default/default-form.phtml deleted file mode 100644 index 2f597822..00000000 --- a/module/Formation/view/formation/default/default-form.phtml +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * @var Form $form - */ - -use Laminas\Form\Form; - -?> - -<?php echo $this->form($form); ?> - -<script> - $(document).ready(function() { - tinymce.remove(); - tinymce.init({ - selector: '.tinymce', - toolbar: 'newdocument undo redo | bold italic underline removeformat | bullist', - resize: true, - language: 'fr_FR', - plugins: 'lists', - statusbar: true, - browser_spellcheck : true, - branding: false, - menu: {}, - body_id: 'description', - setup: function (editor) { - editor.on("focusout", function () { - console.log(tinymce.get('description').getContent()); - $('textarea#description').val(tinymce.get('description').getContent()); - }); - } - }); - }); - - $('select').selectpicker(); -</script> - -<style> - .ui-datepicker{ - position: absolute; - z-index:1050 !important; - } - /*div.ui-datepicker {*/ - /* position: absolute;*/ - /* z-index:1050;*/ - /* }*/ - /* select.ui-datepicker-year option{*/ - /* position: absolute;*/ - /* z-index:3151 !important;*/ - /* }*/ - -</style> \ No newline at end of file diff --git a/module/Formation/view/formation/default/probleme.phtml b/module/Formation/view/formation/default/probleme.phtml deleted file mode 100644 index 55666398..00000000 --- a/module/Formation/view/formation/default/probleme.phtml +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -/** - * @var string $title - * @var string $text - */ - -?> - -<div class="alert alert-danger"> - <p class="lead"> - <?php echo $text; ?> - </p> -</div> - diff --git a/module/Formation/view/formation/default/reponse.phtml b/module/Formation/view/formation/default/reponse.phtml deleted file mode 100644 index 9026c479..00000000 --- a/module/Formation/view/formation/default/reponse.phtml +++ /dev/null @@ -1,8 +0,0 @@ -<?php - -/** - * @var string $reponse - */ - -?> -<?php echo $reponse; ?> -- GitLab