本文整理汇总了PHP中History::undo方法的典型用法代码示例。如果您正苦于以下问题:PHP History::undo方法的具体用法?PHP History::undo怎么用?PHP History::undo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类History
的用法示例。
在下文中一共展示了History::undo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: undo
public function undo()
{
$this->autoRender = false;
if ($this->request->is('post')) {
return json_encode(History::undo($this->Session));
}
}
示例2: undo
public function undo()
{
$ids = explode(',', $this->params()->id);
$this->changes = HistoryChange::emptyCollection();
foreach ($ids as $id) {
$this->changes[] = HistoryChange::where("id = ?", $id)->first();
}
$histories = [];
$total_histories = 0;
foreach ($this->changes as $change) {
if (isset($histories[$change->history_id])) {
continue;
}
$histories[$change->history_id] = true;
$total_histories += 1;
}
if ($total_histories > 1 && !$this->current_user->is_privileged_or_higher()) {
$this->respond_to_error("Only privileged users can undo more than one change at once", ['status' => 403]);
return;
}
$errors = [];
History::undo($this->changes, $this->current_user, $this->params()->redo == "1", $errors);
$error_texts = [];
$successful = 0;
$failed = 0;
foreach ($this->changes as $change) {
$objectHash = spl_object_hash($change);
if (empty($errors[$objectHash])) {
$successful += 1;
continue;
}
$failed += 1;
switch ($errors[$objectHash]) {
case 'denied':
$error_texts[] = "Some changes were not made because you do not have access to make them.";
break;
}
}
$error_texts = array_unique($error_texts);
$this->respond_to_success("Changes made.", ['action' => "index"], ['api' => ['successful' => $successful, 'failed' => $failed, 'errors' => $error_texts]]);
}