本文整理汇总了PHP中AuthItem::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthItem::getErrors方法的具体用法?PHP AuthItem::getErrors怎么用?PHP AuthItem::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthItem
的用法示例。
在下文中一共展示了AuthItem::getErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionManage
/**
* Update an auth item.
* Note: The item's type can not be changed.
*/
public function actionManage($item) {
$item = $this->authManager->getEAuthItem($item);
if (empty($item))
throw new CHttpException(404, Yii::t('RbamModule.rbam','Authorisation item not found.'));
$authItem = new AuthItem('update'); // $authItem is a CFormModel
$attributes = array();
foreach ($authItem->getAttributes() as $name=>$value)
$authItem->$name = $item->$name;
$form = $authItem->getForm(!in_array($item->name, $this->getModule()->getDefaultRoles()));
if ($form->submitted($form->uniqueId)) {
$response = array();
if ($authItem->save($item)) {
$response['content'] = Yii::t('RbamModule.rbam','"{item}" {type} updated.', array(
'{item}'=>$item->name,
'{type}'=>$this->type($item->type, true)
));
if ($item->name!==$_POST['AuthItem']['oldName'])
$response['redirect'] = $this->createUrl($this->action->id, array('item'=>$item->name));
}
else {
$errors = array();
foreach ($authItem->getErrors() as $attribute=>$attributeErrors)
foreach ($attributeErrors as $error)
$errors[] = array(
'attribute'=>$attribute,
'label'=>$authItem->getAttributeLabel($attribute),
'error'=>$error
);
$response = compact('errors');
}
header('Content-type: application/json');
echo CJSON::encode($response);
Yii::app()->end();
}
if (Yii::app()->getUser()->checkAccess($this->getModule()->authAssignmentsManagerRole)) {
$authAssignment = new AuthAssignment('upate'); // $authAssignment is a CFormModel
$assignmentForm = $authAssignment->getForm();
}
else
$assignmentForm = null;
$this->pageTitle = $this->_pageTitle($this->action->id, array(
'{item}'=>$item->name,
'{type}'=>$this->type($item->type, true, true)
));
$this->breadcrumbs = array(
'RBAM'=>array('rbam/index'),
$this->_pageTitle('index')=>array('index'),
$this->pageTitle
);
$this->render('form', compact('item', 'form', 'assignmentForm'));
}