ynh_extension_meeo/controllers/ApiController.php

35 lines
1 KiB
PHP
Raw Normal View History

<?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;
use YesWiki\Meeo\Service\EleveManager;
class ApiController extends YesWikiController
{
/**
* @Route("/api/meeo/eleves",methods={"POST"},options={"acl":{"public"}})
*/
public function eleveUpdate(Request $request) {
$eleveController = $this->getService(EleveManager::class);
$content = $request->getContent();
parse_str($content, $parameters);
$datas = [];
foreach ($parameters as $cle => $valeur) {
$clef_action = explode('_', $cle);
if ($clef_action[1] == 'classe' && $valeur != 'aucune') {
$datas[] = $eleveController->updateClasse($clef_action[0], $valeur);
}
if ($clef_action[1] == 'del') {
$eleveController->del($clef_action[0]);
}
}
return $this->wiki->redirect('?Eleves', 200);
}
}