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