Refactor
This commit is contained in:
parent
6e6d02e658
commit
e818a17371
|
|
@ -43,17 +43,7 @@ class OrganizationController extends AbstractController
|
||||||
if ($this->isGranted("ROLE_SUPER_ADMIN")) {
|
if ($this->isGranted("ROLE_SUPER_ADMIN")) {
|
||||||
$organizations = $this->entityManager->getRepository(Organizations::class)->findBy(['isDeleted' => false]);
|
$organizations = $this->entityManager->getRepository(Organizations::class)->findBy(['isDeleted' => false]);
|
||||||
|
|
||||||
// Map the entities for tabulator
|
|
||||||
$organizationsData = array_map(function($org) {
|
|
||||||
return [
|
|
||||||
'id' => $org->getId(),
|
|
||||||
'name' => $org->getName(),
|
|
||||||
'email' => $org->getEmail(),
|
|
||||||
'logoUrl' => $org->getLogoUrl() ? $org->getLogoUrl() : null, // or prepend base URL if needed
|
|
||||||
'active' => $org->isActive(),
|
|
||||||
'showUrl' => $this->generateUrl('organization_show', ['id' => $org->getId()]),
|
|
||||||
];
|
|
||||||
}, $organizations);
|
|
||||||
} else {
|
} else {
|
||||||
//get all the UO of the user
|
//get all the UO of the user
|
||||||
$uos = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user]);
|
$uos = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user]);
|
||||||
|
|
@ -70,6 +60,17 @@ class OrganizationController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Map the entities for tabulator
|
||||||
|
$organizationsData = array_map(function($org) {
|
||||||
|
return [
|
||||||
|
'id' => $org->getId(),
|
||||||
|
'name' => $org->getName(),
|
||||||
|
'email' => $org->getEmail(),
|
||||||
|
'logoUrl' => $org->getLogoUrl() ? $org->getLogoUrl() : null, // or prepend base URL if needed
|
||||||
|
'active' => $org->isActive(),
|
||||||
|
'showUrl' => $this->generateUrl('organization_show', ['id' => $org->getId()]),
|
||||||
|
];
|
||||||
|
}, $organizations);
|
||||||
return $this->render('organization/index.html.twig', [
|
return $this->render('organization/index.html.twig', [
|
||||||
'organizationsData' => $organizationsData,
|
'organizationsData' => $organizationsData,
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue