solve empty array error
This commit is contained in:
parent
716c7d03c1
commit
2609f41a7c
|
|
@ -37,24 +37,27 @@ class OAuth2Controller extends AbstractController
|
||||||
$uos = $uoRepository->findBy(['users' => $user]);
|
$uos = $uoRepository->findBy(['users' => $user]);
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($uos as $uo) {
|
if (!empty($uos)) {
|
||||||
$result[] = ['organization' => [
|
foreach ($uos as $uo) {
|
||||||
'id' => $uo->getOrganization()->getId(),
|
$result[] = ['organization' => [
|
||||||
'name' => $uo->getOrganization()->getName(),
|
'id' => $uo->getOrganization()->getId(),
|
||||||
'role' => $uo->getRole()->getName()
|
'name' => $uo->getOrganization()->getName(),
|
||||||
]
|
'role' => $uo->getRole()->getName()
|
||||||
];
|
]
|
||||||
if ($uo->getRole()->getName() === "ADMIN") {
|
];
|
||||||
$projets = $uo->getOrganization()->getProjects()->toArray();
|
if ($uo->getRole()->getName() === "ADMIN") {
|
||||||
$result[count($result) - 1]['organization']['projects'] = array_map(function ($projet) {
|
$projets = $uo->getOrganization()->getProjects()->toArray();
|
||||||
return [
|
$result[count($result) - 1]['organization']['projects'] = array_map(function ($projet) {
|
||||||
'id' => $projet->getId(),
|
return [
|
||||||
|
'id' => $projet->getId(),
|
||||||
// 'name' => $projet->getName()
|
// 'name' => $projet->getName()
|
||||||
];
|
];
|
||||||
}, $projets);
|
}, $projets);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->loggerService->logUserAction($user->getId(), $user->getId(), 'Accessed userinfo endpoint');
|
$this->loggerService->logUserAction($user->getId(), $user->getId(), 'Accessed userinfo endpoint');
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
'id' => $user->getId(),
|
'id' => $user->getId(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue