/** * @param Request $request * @param Response $response * @return Response */ public function add($request, $response) { Student::setRegistry($this->registry); $params = $request->getParams(); try { $student = new Student(); $student->setFirstName($params["first_name"]); $student->setSecondName($params["second_name"]); $student->setAge($params["age"]); $student->setGender($params["gender"]); $student->setAddress($params["address"]); $student->save(); } catch (ModelException $e) { $response->setParams(array("exception" => $e->getMessage())); $response->sendRedirect("error"); } $response->sendRedirect("students"); }