当前位置: 首页>>代码示例>>PHP>>正文


PHP History::undo方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:rjawor,项目名称:tagging,代码行数:7,代码来源:HistoryController.php

示例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]]);
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:41,代码来源:HistoryController.php


注:本文中的History::undo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。