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


PHP Operator::findById方法代碼示例

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


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

示例1: editAction

 public function editAction()
 {
     if ($this->isAjax()) {
         $data = $this->request->getPost();
         if (empty($data)) {
             $this->pageError('param');
         }
         $modelForm = new OperatorForm('edit');
         if ($result = $modelForm->validate($data)) {
             if ($modelForm->edit()) {
                 $this->success('操作成功');
             } else {
                 $this->error('操作失敗');
             }
         }
         $this->error($result);
     }
     $oid = $this->dispatcher->getParams()[0];
     if (empty($oid)) {
         $this->pageError('param');
     }
     $operator = Operator::findById($oid);
     if (!$operator) {
         $this->pageError('param');
     }
     $form = new OperatorForm('edit', $operator);
     $this->view->setVars(['page' => ['title' => '編輯成員'], 'formparams' => ['event' => 'edit', 'action' => \Func\url('/operator/edit')], 'data' => $operator]);
     $this->view->pick('operator/add');
 }
開發者ID:Crocodile26,項目名稱:php-1,代碼行數:29,代碼來源:OperatorController.php

示例2: allotAction

 /**
  * 給角色分配權限
  */
 public function allotAction()
 {
     if ($this->isAjax()) {
         $data = $this->request->getPost();
         $data['auth'] = serialize(self::toArray($data['auth']));
         switch ($data['type']) {
             case 'role':
                 $modelForm = new RoleForm('auth');
                 $data['rid'] = $data['id'];
                 unset($data['id']);
                 break;
             case 'operator':
                 $data['oid'] = $data['id'];
                 unset($data['id']);
                 $modelForm = new OperatorForm('auth');
                 break;
             default:
                 $this->error('參數錯誤');
                 break;
         }
         if ($result = $modelForm->validate($data)) {
             if ($modelForm->allot()) {
                 $this->success('操作成功');
             } else {
                 $this->success('操作失敗');
             }
         }
         $this->error('操作失敗');
     }
     $params = $this->dispatcher->getParams();
     $type = $params[0];
     $id = $params[1];
     if (empty($type) || empty($id)) {
         $this->pageError('param');
     }
     switch ($type) {
         case 'role':
             $info = Role::findById($id);
             $modelForm = new RoleForm('auth', $info);
             break;
         case 'operator':
             $info = Operator::findById($id);
             $modelForm = new OperatorForm('auth', $info);
             break;
     }
     $this->view->setVars(['info' => $info, 'form' => $modelForm, 'authorities' => self::allAuthorities(), 'formparams' => ['action' => \Func\url('/authority/allot/role/'), 'type' => $type, 'id' => $id]]);
 }
開發者ID:Crocodile26,項目名稱:php-1,代碼行數:50,代碼來源:AuthorityController.php


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