當前位置: 首頁>>代碼示例>>PHP>>正文


PHP plugins::delete方法代碼示例

本文整理匯總了PHP中plugins::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP plugins::delete方法的具體用法?PHP plugins::delete怎麽用?PHP plugins::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plugins的用法示例。


在下文中一共展示了plugins::delete方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: formDelete

 /**
  * Performs de-population of model :)
  *
  * @param object The base object to save
  * @param string The message to display if successful
  * @return bool
  */
 protected function formDelete(&$object, $deleteMessage = NULL, $deleteEvents = array())
 {
     // Delete data and all relations
     try {
         // Bring out the Gimp.
         $conn = Doctrine_Manager::connection();
         $conn->beginTransaction();
         $this->delete_prepare($object);
         // Allow plugins to process any data related to this object prior to deletion
         if (!plugins::delete($this, $deleteEvents)) {
             throw new Bluebox_Exception('Plugins failed to delete');
         }
         $this->pre_delete($object);
         // Delete this base record
         $object->delete();
         $conn->commit();
         $this->post_delete($object);
         // Success - optionally set a delete message
         if (is_null($deleteMessage)) {
             $displayName = inflector::humanizeModelName(get_class($object));
             message::set($displayName . ' removed!', array('type' => 'success'));
         } else {
             if (!empty($deleteMessage)) {
                 message::set($deleteMessage, array('type' => 'success'));
             }
         }
         $this->delete_succeeded($object);
         return TRUE;
     } catch (Doctrine_Connection_Exception $e) {
         message::set('Doctrine error: ' . $e->getMessage());
     } catch (Bluebox_Exception $e) {
         message::set('Please correct the errors listed below.');
         kohana::log('alert', $e->getMessage());
     } catch (Exception $e) {
         message::set($e->getMessage());
     }
     if ($conn) {
         $conn->rollback();
     }
     $this->delete_failed($object);
     return FALSE;
 }
開發者ID:Jaybee-,項目名稱:bluebox,代碼行數:49,代碼來源:bluebox.php

示例2: restfulDelete

 /**
  * This function preforms the default restful delete,
  * extend this class and redefine if you need different behavoir.
  *
  * @return void
  */
 public function restfulDelete()
 {
     $errorOccured = FALSE;
     kohana::log('debug', 'Attempting a RESTful delete');
     if (empty($_POST['id'])) {
         message::set('No rows where specified for delete', array('type' => 'alert'));
         return;
     }
     $delIDs = explode(',', $_POST['id']);
     $conn = Doctrine_Manager::connection();
     foreach ($delIDs as $delID) {
         $row = Doctrine::getTable($this->baseModel)->find($delID);
         if (!$row) {
             $errorOccured = TRUE;
             message::set('Unable to locate row ' . strtolower($this->baseModel) . ' id ' . $delID . '!');
             continue;
         }
         try {
             Bluebox_Record::setBaseSaveObject($row);
             $conn->beginTransaction();
             plugins::delete($row);
             $row->delete();
             $conn->commit();
             plugins::delete($row, array('custom' => Router::$controller . '.success', 'coreAction' => FALSE, 'core' => FALSE));
             Bluebox_Record::setBaseSaveObject(NULL);
         } catch (Exception $e) {
             $errorOccured = TRUE;
             message::set('Unable to delete ' . strtolower($this->baseModel) . ' id ' . $delID . '! ' . $e->getMessage());
         }
     }
     if (empty($errorOccured)) {
         message::set('Selected record(s) deleted.', array('type' => 'success'));
     }
 }
開發者ID:swk,項目名稱:bluebox,代碼行數:40,代碼來源:jgrid.php


注:本文中的plugins::delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。