public function add() { if (Kadmin::already($_POST['id'])) { throw new Exception('KADMIN ALREADY EXISTS', 409); } $admin = new Kadmin(); $admin->setId($_POST['id']); $admin->setPassword($_POST['password']); $admin->setDisplayName($_POST['displayName']); $admin->setType($_POST['type']); if (array_key_exists('mail', $_POST)) { $admin->setMail($_POST['mail']); } $admin->save(); return array('kadminId' => $admin->getId()); }