ptut-vhost/build/api/module/ue/tpController.php

46 lines
865 B
PHP

<?php
namespace api\module\ue;
use database\core\Repo;
use database\repo\tp;
use error\core\Error;
use error\core\Err;
class tpController{
/* (1) Get groups for a specific UE
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
*
---------------------------------------------------------*/
public static function get($args){
$code = "";
extract($args);
/* Get the tp repo */
/** @var tp $tp_repo */
$tp_repo = Repo::getRepo('tp');
/* (1) Try to fetch data */
$fetched = $tp_repo->getGroups($code);
/* (2) Manage error */
if( is_null($fetched) || !is_array($fetched) )
return ['error' => new Error(Err::RepoError)];
/* (3) Parse JSON list */
foreach($fetched as $f=>$v)
$fetched[$f]['formations'] = json_decode($v['formations']);
return ['groups' => $fetched];
}
}