本文整理匯總了PHP中Gateway::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gateway::delete方法的具體用法?PHP Gateway::delete怎麽用?PHP Gateway::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Gateway
的用法示例。
在下文中一共展示了Gateway::delete方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: delete
/**
* Delete one or more documents
*
* @param $docs
*/
public function delete($docs)
{
if ($docs instanceof Document) {
$this->obj_gateway->delete([$docs->getId()]);
} elseif (is_string($docs)) {
$this->obj_gateway->delete([$docs]);
} elseif (is_array($docs)) {
$arr_doc_ids = [];
foreach ($docs as $doc) {
if ($doc instanceof Document) {
$arr_doc_ids[] = $doc->getId();
} elseif (is_string($doc)) {
$arr_doc_ids[] = $doc;
} else {
throw new \InvalidArgumentException('Parameter must be one or more \\Search\\Document objects or ID strings');
}
}
$this->obj_gateway->delete($arr_doc_ids);
} else {
throw new \InvalidArgumentException('Parameter must be one or more \\Search\\Document objects or ID strings');
}
}
示例2: deleteAction
function deleteAction()
{
$id = AF::get($_POST, 'id', 0);
$modelsID = explode(',', $id);
$errors = FALSE;
foreach ($modelsID as $id) {
$model = new Gateway();
$model->model_uset_id = $this->user->user_id;
if ($model->findByPk($id)) {
$model->delete($id);
} else {
$errors = TRUE;
}
if ($model->getErrors()) {
$errors = TRUE;
}
unset($model);
}
if (isset($_POST['ajax'])) {
AF::setJsonHeaders('json');
if ($errors) {
Message::echoJsonError(__('gateway_not_deleted'));
} else {
$countE = AF::get($_POST, 'countE', 100000);
if (count($modelsID) >= $countE) {
$link = AF::link(array('gateways' => 'view'));
Message::echoJsonRedirect($link);
} else {
Message::echoJsonSuccess(__('gateway_deleted'));
}
}
}
$this->redirect();
}