Rajout de config pour les redirections de l'API

This commit is contained in:
Mickael Veaudour 2024-07-30 10:48:11 +02:00
parent ea96d02bcf
commit 1c97e494b8
No known key found for this signature in database
2 changed files with 16 additions and 5 deletions

View file

@ -5,6 +5,10 @@ parameters:
notesFormId: 8
yunohostFormId: 5
groupeEE: 'EquipeEducative'
redirect:
eleveUpdate: '?Eleves'
controle: '?Bulletin'
absence: '?voir_absences'
services:
_defaults:
autowire: true
@ -14,5 +18,5 @@ services:
resource: 'services/*'
# Allows to use controllers as services
# YesWiki\MeeO\Controller\:
# resource: 'controllers/*'
YesWiki\MeeO\Controller\:
resource: 'controllers/*'

View file

@ -1,6 +1,7 @@
<?php
namespace YesWiki\Meeo\Controller;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -12,6 +13,12 @@ use YesWiki\Meeo\Service\NoteManager;
class ApiController extends YesWikiController
{
private $redirectParams;
public function __construct(ParameterBagInterface $params) {
$this->redirectParams = $params->get('meeo')['redirect'];
}
/**
* @Route("/api/meeo/eleves",methods={"POST"},options={"acl":{"public"}})
*/
@ -36,7 +43,7 @@ class ApiController extends YesWikiController
}
}
// return new ApiResponse($data);
return $this->wiki->redirect('?Eleves', 200);
return $this->wiki->redirect($this->redirectParams['eleveUpdate'], 200);
}
/**
@ -57,7 +64,7 @@ class ApiController extends YesWikiController
$controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['coef'], $eleves);
$controle->createNotes($noteManager);
// return new ApiResponse($controle);
return $this->wiki->redirect('?Bulletin', 200);
return $this->wiki->redirect($this->redirectParams['controle'], 200);
}
/**
@ -69,6 +76,6 @@ class ApiController extends YesWikiController
parse_str($content, $parameters);
return new ApiResponse($parameters);
// return $this->wiki->redirect('?Bulletin', 200);
// return $this->wiki->redirect($this->redirectParams['absence'], 200);
}
}