public function upsertUserAction($id = null)
{
$data = ['groups' => $this->gk_groups, 'groupnames' => []];
if ($id) {
$user = Gatekeeper::findUserById($id);
if (!$user) {
$this->flasher->error('User with ID ' . $id . ' not found!');
$this->redirect('/users');
}
$data['user'] = $user;
foreach ($user->groups as $group) {
$data['groupnames'][] = $group->name;
}
}
echo $this->twig->render('users/upsert.twig', $data);
}