/** * Persists the entity data found in the request. * * @param Request $req The request instance * @param Response $res The response instance * * @return void * @see IndexServlet::indexAction() */ public function persistAction(Request $req, Response $res) { // load the params with the entity data $parameterMap = $req->getParams(); // check if the necessary params has been specified and are valid if (!array_key_exists('sampleId', $parameterMap)) { throw new \Exception(); } else { $sampleId = filter_var($parameterMap['sampleId'], FILTER_VALIDATE_INT); } if (!array_key_exists('name', $parameterMap)) { throw new \Exception(); } else { $name = filter_var($parameterMap['name'], FILTER_SANITIZE_STRING); } // create a new entity and persist it $entity = new Sample(); $entity->setSampleId((int) $sampleId); $entity->setName($name); $this->getProxy(self::PROXY_CLASS)->persist($entity); // reload all entities and render the dialog $this->indexAction($req, $res); }