예제 #1
0
 /**
  * Deletes a perfil
  *
  * @param string $id
  */
 public function deleteAction()
 {
     try {
         if (!$this->request->isPost()) {
             throw new Exception('Acesso não permitido a essa action.');
         }
         if ($this->request->isAjax()) {
             $this->view->disable();
         }
         $id = $this->request->getPost('id');
         $perfil = Perfils::findFirstByid($id);
         if (!$perfil) {
             throw new Exception('Perfil não encontrado!');
         }
         if (!$perfil->delete()) {
             $msg = '';
             foreach ($perfil->getMessages() as $message) {
                 $msg .= $message . '<br />';
             }
             throw new Exception($msg);
         }
         echo 'ok';
     } catch (Exception $exc) {
         $this->flash->error($exc->getMessage());
         return $this->response->redirect('nucleo/perfils');
     }
 }