Exemple #1
0
 public function rest_delete()
 {
     $snippet_name = $this->param('name', NULL, TRUE);
     $snippet = new Model_File_Snippet($snippet_name);
     if (!$snippet->is_exists()) {
         throw HTTP_API_Exception::factory(API::ERROR_PAGE_NOT_FOUND, 'Snippet :name not found!', array(':name' => $snippet_name));
     }
     if ($snippet->delete()) {
         $this->response($snippet);
     } else {
         throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Snippet :name has not been deleted!', array(':name' => $snippet_name));
     }
 }
Exemple #2
0
 public function action_delete()
 {
     $this->auto_render = FALSE;
     $snippet_name = $this->request->param('id');
     $snippet = new Model_File_Snippet($snippet_name);
     // find the user to delete
     if ($snippet->is_exists()) {
         if ($snippet->delete()) {
             Kohana::$log->add(Log::INFO, 'Snippet :name has been deleted by :user', array(':name' => $snippet_name))->write();
             Messages::success(__('Snippet has been deleted!'));
             Observer::notify('snippet_after_delete', $snippet_name);
         } else {
             Messages::errors(__('Something went wrong!'));
         }
     } else {
         Messages::errors(__('Snippet not found!'));
     }
     $this->go();
 }