本文整理汇总了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;
}
示例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'));
}
}