/**
  * Deletes a menu
  *
  * @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');
         $menu = Menus::findFirstByid($id);
         if (!$menu) {
             throw new Exception('Menu não encontrado!');
         }
         if (!$menu->delete()) {
             $msg = '';
             foreach ($menu->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/menus');
     }
 }