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]);
|
||||
|
||||
$result = [];
|
||||
foreach ($uos as $uo) {
|
||||
$result[] = ['organization' => [
|
||||
'id' => $uo->getOrganization()->getId(),
|
||||
'name' => $uo->getOrganization()->getName(),
|
||||
'role' => $uo->getRole()->getName()
|
||||
]
|
||||
];
|
||||
if ($uo->getRole()->getName() === "ADMIN") {
|
||||
$projets = $uo->getOrganization()->getProjects()->toArray();
|
||||
$result[count($result) - 1]['organization']['projects'] = array_map(function ($projet) {
|
||||
return [
|
||||
'id' => $projet->getId(),
|
||||
if (!empty($uos)) {
|
||||
foreach ($uos as $uo) {
|
||||
$result[] = ['organization' => [
|
||||
'id' => $uo->getOrganization()->getId(),
|
||||
'name' => $uo->getOrganization()->getName(),
|
||||
'role' => $uo->getRole()->getName()
|
||||
]
|
||||
];
|
||||
if ($uo->getRole()->getName() === "ADMIN") {
|
||||
$projets = $uo->getOrganization()->getProjects()->toArray();
|
||||
$result[count($result) - 1]['organization']['projects'] = array_map(function ($projet) {
|
||||
return [
|
||||
'id' => $projet->getId(),
|
||||
// 'name' => $projet->getName()
|
||||
];
|
||||
}, $projets);
|
||||
];
|
||||
}, $projets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->loggerService->logUserAction($user->getId(), $user->getId(), 'Accessed userinfo endpoint');
|
||||
return new JsonResponse([
|
||||
'id' => $user->getId(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue