Merge branch 'master' into dist/envole/6/master

This commit is contained in:
Arnaud Fornerot 2021-03-12 11:52:45 +01:00
commit 1461ceca06
2 changed files with 74 additions and 0 deletions

View File

@ -39,6 +39,72 @@ use Cadoles\EdispatcherBundle\Entity\Datasource;
class ApiController extends Controller
{
public function applicationsAction() {
$itemcategorys = $this->getDoctrine()->getRepository('CadolesPortalBundle:Itemcategory')->findBy(
[], ['rowOrder' => 'asc']);
$groups = $this->getDoctrine()->getRepository('CadolesCoreBundle:Group')->findBy([], ['label' =>
'asc']);
foreach($itemcategorys as $itemcategory) {
$items = $itemcategory->getItems();
foreach($items as $item) {
$output = [];
$output["id"] = $item->getId();
$output["name"] = $item->getTitle();
$output["libelle"] = $item->getSubtitle();
$output["icon"] = $item->getIcon()?$item->getIcon()->getLabel():"default";
$output["url"] = $item->getUrl();
$output["profils"] = [];
foreach($item->getGroups() as $group) {
$output["profils"]["groupes"][] = "NINEGATE|".$group->getLabel();
}
foreach($item->getRoles() as $role) {
$output["profils"]["roles"][] = "NINEGATE|".$role;
}
if ($item->getSsoitem()!="") $output["profils"]["SSOITEM"] = $item->getSsoitem();
$reponse[$item->getTitle()] = $output;
}
}
return new Response(json_encode($reponse), Response::HTTP_OK);
}
public function checkuserAction() {
$em = $this->getDoctrine()->getManager();
$request = $this->container->get('request_stack')->getCurrentRequest();
$id = $request->query->get('id',false);
if ($id) {
$user=$em->getRepository('CadolesCoreBundle:User')->findOneBy(["username"=>$id]);
if (!$user) {
$output["error"]="id=".$id." : user not found";
return new Response(json_encode($output), 400);
}
$output["username"] = $user->getUsername();
$output["firstname"] = $user->getFirstname();
$output["lastname"] = $user->getLastname();
$output["email"] = $user->getEmail();
$output["role"] = $user->getRole();
foreach($user->getGroups() as $group) {
$output["groupes"][] = $group->getGroup()->getLabel();
}
} else {
$output["error"]="id needed";
return new Response(json_encode($output), 404);
}
return new Response(json_encode($output), Response::HTTP_OK);
}
public function testAction() {
$em = $this->getDoctrine()->getManager();

View File

@ -25,6 +25,14 @@ cadoles_edispatcher_api_public_hello:
path: /edispatcher/api/public/hello
defaults: { _controller: CadolesEdispatcherBundle:Api:hello }
cadoles_edispatcher_api_applications:
path: /edispatcher/api/applications
defaults: { _controller: CadolesEdispatcherBundle:Api:applications }
cadoles_edispatcher_api_checkuser:
path: /edispatcher/api/checkuser
defaults: { _controller: CadolesEdispatcherBundle:Api:checkuser }
cadoles_edispatcher_api_apps_all:
path: /edispatcher/api/apps/all
defaults: { _controller: CadolesEdispatcherBundle:Api:hello }