Fix apiController

This commit is contained in:
mckmonster 2024-08-03 11:56:26 +02:00
parent 12d9bff044
commit 60c7958066

View file

@ -21,14 +21,17 @@ class ApiController extends YesWikiController
{
private $redirectParams;
public function __construct(ParameterBagInterface $params) {
$this->redirectParams = $params->get('meeo')['redirect'];
public function __construct() {
}
/**
* @Route("/api/meeo/eleves",methods={"POST"},options={"acl":{"public"}})
*/
public function eleveUpdate(Request $request) {
$params = $this->getService(ParameterBagInterface::class);
$redirectParams = $params->get('meeo')['redirect'];
$eleveController = $this->getService(EleveManager::class);
$content = $request->getContent();
@ -49,13 +52,16 @@ class ApiController extends YesWikiController
}
}
// return new ApiResponse($data);
return $this->wiki->redirect($this->redirectParams['eleveUpdate'], 200);
return $this->wiki->redirect($redirectParams['eleveUpdate'], 200);
}
/**
* @Route("/api/meeo/controle",methods={"POST"},options={"acl":{"public"}})
*/
public function controle(Request $request) {
$params = $this->getService(ParameterBagInterface::class);
$redirectParams = $params->get('meeo')['redirect'];
$noteManager = $this->getService(NoteManager::class);
$content = $request->getContent();
@ -70,13 +76,15 @@ 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($this->redirectParams['controle'], 200);
return $this->wiki->redirect($redirectParams['controle'], 200);
}
/**
* @Route("/api/meeo/absence",methods={"POST"},options={"acl":{"public"}})
*/
public function absence(Request $request) {
$params = $this->getService(ParameterBagInterface::class);
$redirectParams = $params->get('meeo')['redirect'];
$content = $request->getContent();
parse_str($content, $parameters);
@ -104,7 +112,7 @@ class ApiController extends YesWikiController
if (!send_mail($expediteur['email'], $expediteur['name'], $destinataire, "Absence", $body, $body))
echo "Erreur d'envoie de mail";
return new ApiResponse($parameters);
// return $this->wiki->redirect($this->redirectParams['absence'], 200);
// return new ApiResponse($parameters);
return $this->wiki->redirect($redirectParams['absence'], 200);
}
}