ynh_extension_meeo/controllers/ApiController.php
mckmonster 1ace33f690 [Eleves] Rajout d'une APi pour update les élèves.
Il faut que je fasse le code dedans.
2024-07-17 19:15:22 +02:00

38 lines
No EOL
975 B
PHP

<?php
namespace YesWiki\Meeo\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use YesWiki\Core\ApiResponse;
use YesWiki\Core\YesWikiController;
class ApiController extends YesWikiController
{
/**
* @Route("/api/meeo/eleves",methods={"POST"},options={"acl":{"public"}})
*/
public function eleveUpdate(Request $request) {
$content = $request->getContent();
parse_str($content, $parameters);
$result = [];
foreach ($parameters as $cle => $valeur) {
$clef_action = explode('_', $cle);
if ($clef_action[1] == 'classe' && $valeur != 'aucune') {
$result[] = 'Change la classe de '.$clef_action[0].' pour '.$valeur;
}
if ($clef_action[1] == 'del') {
$result[] = 'Suppression de '.$clef_action[0];
}
}
return new ApiResponse(
['result'=> $result],
Response::HTTP_CREATED
);
}
}