Skip to content
Snippets Groups Projects
Select Git revision
  • 3b8e1694e505bbc8f643f74b27a63df2a8c812bf
  • master default protected
  • b24
  • ll-framework
  • ll-wf-finitions
  • ll-workflow
  • alc-scindage-donnees-pj
  • FJ_LL_Tbl_Contrat
  • alc-docker-node
  • ll-apiplatform
  • php84
  • ll-rgpd
  • b23
  • alc-filtre-type-intervenant
  • ll-sans-mdb5
  • formules-ancienne-infra
  • ll-formules
  • alc-intervenant-dmep
  • ll-suppr-v_vol-s
  • b20
  • ll-postgresql
  • 24.11
  • 24.10
  • 24.9
  • 24.8
  • 24.7
  • 24.6
  • 24.5
  • 24.4
  • 24.3
  • 24.2
  • 24.1
  • 24.0
  • 23.15
  • 24.0-beta19
  • 24.0-beta18
  • 24.0-beta17
  • 24.0-beta16
  • 24.0-beta15
  • 24.0-beta14
  • 24.0-beta13
41 results

Anonymisation.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    NoteController.php 3.19 KiB
    <?php
    
    namespace UnicaenEgracon\Controller;
    
    use Laminas\Mvc\Controller\AbstractActionController;
    use Laminas\View\Model\ViewModel;
    use UnicaenEgracon\Entity\Db\Note;
    use UnicaenEgracon\Form\Note\NoteFormAwareTrait;
    use UnicaenEgracon\Service\Note\NoteServiceAwareTrait;
    
    class NoteController extends AbstractActionController {
        use NoteServiceAwareTrait;
        use NoteFormAwareTrait;
    
        public function indexAction() : ViewModel
        {
            $notes = $this->getNoteService()->getNotes();
            return new ViewModel([
                'notes' => $notes,
            ]);
        }
    
        public function afficherAction() : ViewModel
        {
            $note = $this->getNoteService()->getRequestedNote($this);
    
            return new ViewModel([
                'title' => "Affichage d'une note",
                'note' => $note,
            ]);
        }
    
        public function ajouterAction() : ViewModel
        {
            $note = new Note();
    
            $form = $this->getNoteForm();
            $form->setAttribute('action', $this->url()->fromRoute('egracon/note/ajouter', [], [], true));
            $form->bind($note);
    
            $request = $this->getRequest();
            if ($request->isPost()) {
                $data = $request->getPost();
                $form->setData($data);
                if ($form->isValid()) {
                    $this->getNoteService()->create($note);
                    exit();
                }
            }
            $vm = new ViewModel([
                'title' => "Ajouter un note",
                'form' => $form,
            ]);
            $vm->setTemplate('unicaen-egracon/default/default-form');
            return $vm;
        }
    
        public function modifierAction() : ViewModel
        {
            $note = $this->getNoteService()->getRequestedNote($this);
    
            $form = $this->getNoteForm();
            $form->setAttribute('action', $this->url()->fromRoute('egracon/note/modifier', ['note' => $note->getId()], [], true));
            $form->bind($note);
    
            $request = $this->getRequest();
            if ($request->isPost()) {
                $data = $request->getPost();
                $form->setData($data);
                if ($form->isValid()) {
                    $this->getNoteService()->update($note);
                    exit();
                }
            }
            $vm = new ViewModel([
                'title' => "Modifier le note [".$note->getId()."]",
                'form' => $form,
            ]);
            $vm->setTemplate('unicaen-egracon/default/default-form');
            return $vm;
        }
    
        public function supprimerAction(): ViewModel
        {
            $note = $this->getNoteService()->getRequestedNote($this);
    
            $request = $this->getRequest();
            if ($request->isPost()) {
                $data = $request->getPost();
                if ($data["reponse"] === "oui") $this->getNoteService()->delete($note);
                exit();
            }
    
            $vm = new ViewModel();
            if ($note !== null) {
                $vm->setTemplate('unicaen-egracon/default/confirmation');
                $vm->setVariables([
                    'title' => "Suppression du note " . $note->getId(),
                    'text' => "La suppression est définitive êtes-vous sûr&middot;e de vouloir continuer ?",
                    'action' => $this->url()->fromRoute('egracon/note/supprimer', ["note" => $note->getId()], [], true),
                ]);
            }
            return $vm;
        }
    }