/**
  * Deletes a controller
  *
  * @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');
         $categoryDocument = CategoriesDocuments::findFirstByid($id);
         if (!$categoryDocument) {
             throw new Exception('Documentos de Categorias não encontrado!');
         }
         if (!$categoryDocument->delete()) {
             $msg = '';
             foreach ($categoryDocument->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/categories_documents');
     }
 }