Removed unused functions
This commit is contained in:
parent
70842d6fe9
commit
52b8ba0a10
|
|
@ -133,35 +133,6 @@ class UserService
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Organizations id where the user is admin
|
||||
*
|
||||
* @param User $user
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAdminOrganizationsIds(User $user): array
|
||||
{
|
||||
$orgIds = [];
|
||||
try {
|
||||
$uo = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user]);
|
||||
$roleAdmin = $this->entityManager->getRepository(Roles::class)->findOneBy(['name' => 'ADMIN']);
|
||||
if ($uo) {
|
||||
foreach ($uo as $u) {
|
||||
$uoa = $this->entityManager->getRepository(UserOrganizatonApp::class)->findOneBy(['userOrganization' => $u,
|
||||
'role' => $roleAdmin,
|
||||
'isActive' => true]);
|
||||
if ($uoa && $this->security->isGranted('ROLE_ADMIN')) {
|
||||
$orgIds[] = $u->getOrganization()->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (EntityNotFoundException $e) {
|
||||
throw new EntityNotFoundException("Error while fetching organizations ids where the user is admin");
|
||||
}
|
||||
|
||||
return array_unique($orgIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user by their identifier.
|
||||
|
|
@ -179,45 +150,6 @@ class UserService
|
|||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users grouped by their organizations for the index page.
|
||||
* This method should return an array of users grouped by their organizations.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function groupByOrganization(array $usersOrganizations): array
|
||||
{
|
||||
$grouped = [];
|
||||
|
||||
foreach ($usersOrganizations as $userOrg) {
|
||||
$org = $userOrg->getOrganization();
|
||||
if (!$org) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$orgId = $org->getId();
|
||||
$orgName = $org->getName();
|
||||
$orgLogo = $org->getLogoUrl();
|
||||
|
||||
if (!isset($grouped[$orgId])) {
|
||||
$grouped[$orgId] = [
|
||||
'id' => $orgId,
|
||||
'name' => $orgName,
|
||||
'logo' => $orgLogo,
|
||||
'users' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$user = $userOrg->getUsers();
|
||||
$grouped[$orgId]['users'][] = [
|
||||
'entity' => $user,
|
||||
'connected' => $this->isUserConnected($user->getUserIdentifier()),
|
||||
'isActive' => (bool)$userOrg->isActive()
|
||||
];
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format users without organization for admin view.
|
||||
|
|
|
|||
Loading…
Reference in New Issue