1 | <?php |
2 | |
3 | require_once __DIR__ . "/../lib/php/ejecutaServicio.php"; |
4 | require_once __DIR__ . "/../lib/php/JsonResponse.php"; |
5 | require_once __DIR__ . "/../lib/php/leeTexto.php"; |
6 | require_once __DIR__ . "/../lib/php/leeArray.php"; |
7 | require_once __DIR__ . "/modelo/Rol.php"; |
8 | require_once __DIR__ . "/modelo/Usuario.php"; |
9 | require_once __DIR__ . "/bd/usuarioAgrega.php"; |
10 | |
11 | ejecutaServicio(function () { |
12 | $cue = leeTexto("cue"); |
13 | $rolIds = leeArray("rolIds"); |
14 | |
15 | $roles = []; |
16 | if ($rolIds !== null) { |
17 | foreach ($rolIds as $rolId) { |
18 | $roles[] = new Rol(id: $rolId); |
19 | } |
20 | } |
21 | $modelo = new Usuario(cue: $cue === null ? "" : trim($cue), roles: $roles); |
22 | usuarioAgrega($modelo); |
23 | $id = htmlentities($modelo->id); |
24 | return JsonResponse::created("/srv/srvUsuarioBusca.php?id=$id", $modelo); |
25 | }); |
26 | |