Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

创建角色时报这个错误 #3

Open
kylinlxl opened this issue Jan 5, 2018 · 1 comment
Open

创建角色时报这个错误 #3

kylinlxl opened this issue Jan 5, 2018 · 1 comment

Comments

@kylinlxl
Copy link

kylinlxl commented Jan 5, 2018

PHP Warning – yii\base\ErrorException
Missing argument 1 for izyue\admin\models\AuthItem::find(), called in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\validators\UniqueValidator.php on line 210 and defined

1. in D:\yii2\yii2-app-advanced\vendor\izyue\yii2-admin\models\AuthItem.php at line 115
106107108109110111112113114115116117118119120121122123124

    {
        return $this->_item === null;
    }
 
    /**
     * Find role
     * @param string $id
     * @return null|\self
     */
    public static function find($id)
    {
        $item = Yii::$app->authManager->getRole($id);
        if ($item !== null) {
            return new self($item);
        }
 
        return null;
    }
 

2. in D:\yii2\yii2-app-advanced\vendor\izyue\yii2-admin\models\AuthItem.php at line 115 – yii\base\ErrorHandler::handleError(2, 'Missing argument 1 for izyue\adm...', 'D:\yii2\yii2-app-advanced\vendor...', 115, ...)
109110111112113114115116117118119120121

 
    /**
     * Find role
     * @param string $id
     * @return null|\self
     */
    public static function find($id)
    {
        $item = Yii::$app->authManager->getRole($id);
        if ($item !== null) {
            return new self($item);
        }
 

3. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\validators\UniqueValidator.php at line 210 – izyue\admin\models\AuthItem::find()
4. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\validators\UniqueValidator.php at line 165 – yii\validators\UniqueValidator::prepareQuery('izyue\admin\models\AuthItem', ['and', ['name' => '普通管理员']])
5. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\validators\UniqueValidator.php at line 134 – yii\validators\UniqueValidator::modelExists('izyue\admin\models\AuthItem', ['and', ['name' => '普通管理员']], izyue\admin\models\AuthItem)
6. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\validators\Validator.php at line 267 – yii\validators\UniqueValidator::validateAttribute(izyue\admin\models\AuthItem, 'name')
7. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\base\Model.php at line 360 – yii\validators\Validator::validateAttributes(izyue\admin\models\AuthItem, ['name'])
8. in D:\yii2\yii2-app-advanced\vendor\izyue\yii2-admin\models\AuthItem.php at line 131 – yii\base\Model::validate()
125126127128129130131132133134135136137

    /**
     * Save role to [[\yii\rbac\authManager]]
     * @return boolean
     */
    public function save()
    {
        if ($this->validate()) {
            $manager = Yii::$app->authManager;
            if ($this->_item === null) {
                if ($this->type == Item::TYPE_ROLE) {
                    $this->_item = $manager->createRole($this->name);
                } else {
                    $this->_item = $manager->createPermission($this->name);

9. in D:\yii2\yii2-app-advanced\vendor\izyue\yii2-admin\components\ItemController.php at line 74 – izyue\admin\models\AuthItem::save()
68697071727374757677787980

     * @return mixed
     */
    public function actionCreate()
    {
        $model = new AuthItem(null);
        $model->type = $this->type;
        if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
            Helper::invalidate();
 
            return $this->redirect(['view', 'id' => $model->name]);
        } else {
            return $this->render('create', ['model' => $model]);
        }

10. izyue\admin\components\ItemController::actionCreate()
11. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\base\InlineAction.php at line 57 – call_user_func_array([izyue\admin\controllers\RoleController, 'actionCreate'], [])
12. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\base\Controller.php at line 157 – yii\base\InlineAction::runWithParams([])
13. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\base\Module.php at line 528 – yii\base\Controller::runAction('create', [])
14. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\web\Application.php at line 103 – yii\base\Module::runAction('admin/role/create', [])
15. in D:\yii2\yii2-app-advanced\vendor\yiisoft\yii2\base\Application.php at line 386 – yii\web\Application::handleRequest(yii\web\Request)
16. in D:\yii2\yii2-app-advanced\backend\web\index.php at line 18 – yii\base\Application::run()
12131415161718

    require(__DIR__ . '/../../common/config/main-local.php'),
    require(__DIR__ . '/../config/main.php'),
    require(__DIR__ . '/../config/main-local.php')
);
 
$application = new yii\web\Application($config);
$application->run();

$_POST = [
'_csrf' => '3uWVuZ6Gy2yK0MWi300avyxrqNhChjPsGu8xRcUa3By50OXP1-6NLcaDlZSdKE3wRg3C6hbPVYtirgAWmnWNKg==',
'AuthItem' => [
'name' => '普通管理员',
'description' => '普通管理员',
'ruleName' => '',
'data' => '',
],
];

$_COOKIE = [
'PHPSESSID' => 'pseqh23e7k746jcdsn9pmcdhg7',
'_csrf' => 'eee76ccb2c201cf205711c06f29d1059ae4256777d27a1c731a9012b91abec31a:2:{i:0;s:5:"_csrf";i:1;s:32:"g5pvIhFALSP6BeWOjfj2TIfgxA1S_oQ6";}',
];

$_SESSION = [
'__flash' => [],
'__returnUrl' => '/admin/route/index',
'__id' => 1,
];

Yii Framework

2018-01-05, 11:44:08

nginx/1.11.5

Yii Framework/2.0.13.1

@yyggg
Copy link

yyggg commented Jan 18, 2018

我也是。你解决没

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants