getAccessChecker()->canManageAccesses()) { throw new Forbidden(); } $user = $this->getUserRepository()->get($userId); if ($this->request->isPost()) { $validation = new Validation([ 'role' => 'required', ]); $validation->validate($_POST); $initiator = $this->getAuth()->getUserFromSession(); $user->assignRole(Role::fromValue($_POST['role']), $initiator->id); $this->response->redirect('/users/' . $userId); return; } echo $this->view->render( __DIR__ . '/../Views/assign-role', ['user1' => $user] ); } private function getUserRepository(): UserRepository { return new UserRepository(); } private function getAccessChecker(): AccessChecker { return new AccessChecker(); } private function getAuth(): Auth { return new Auth(); } }