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


PHP Profile::initProfile方法代码示例

本文整理汇总了PHP中app\models\Profile::initProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::initProfile方法的具体用法?PHP Profile::initProfile怎么用?PHP Profile::initProfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Profile的用法示例。


在下文中一共展示了Profile::initProfile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionInit

 public function actionInit()
 {
     //roles
     //user admin psychologist school
     $auth = Yii::$app->authManager;
     //$user = $auth->createRole('user');
     $adminUser = new User();
     $adminUser->email = 'admin@gmail.com';
     $adminUser->setPassword('123456');
     $adminUser->generateAuthKey();
     $adminUser->save();
     $admin = $auth->createRole('admin');
     $auth->add($admin);
     $averageUser = new User();
     $averageUser->email = 'user@gmail.com';
     $averageUser->setPassword('123456');
     $averageUser->generateAuthKey();
     $averageUser->save();
     $profile = new Profile();
     $model = new SignupForm();
     $model->first_name = "Юзер";
     $model->last_name = "Юзерович";
     $model->second_name = "Юзеров";
     $profile->initProfile($model, $averageUser->id);
     $user = $auth->createRole('user');
     $auth->add($user);
     /*        $accessAdmin = $auth->createPermission('accessAdmin');
               $accessAdmin->description = 'Access admin';
               $auth->add($accessAdmin);
               $auth->addChild($admin, $accessAdmin);*/
     //$psychologist = $auth->createRole('psychologist');
     /*// add "createPost" permission
             $createPost = $auth->createPermission('createPost');
             $createPost->description = 'Create a post';
             $auth->add($createPost);
     
             // add "updatePost" permission
             $updatePost = $auth->createPermission('updatePost');
             $updatePost->description = 'Update post';
             $auth->add($updatePost);
     
             // add "author" role and give this role the "createPost" permission
             $author = $auth->createRole('author');
             $auth->add($author);
             $auth->addChild($author, $createPost);
     
             // add "admin" role and give this role the "updatePost" permission
             // as well as the permissions of the "author" role
             $admin = $auth->createRole('admin');
             $auth->add($admin);
             $auth->addChild($admin, $updatePost);
             $auth->addChild($admin, $author);
     
             // Assign roles to users. 1 and 2 are IDs returned by IdentityInterface::getId()
             // usually implemented in your User model.
             $auth->assign($author, 2);*/
     $auth->assign($admin, 1);
     $auth->assign($user, 2);
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:59,代码来源:RbacController.php

示例2: actionSignup

 public function actionSignup()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             $profile = new Profile();
             if ($profile->initProfile($model, $user->id)) {
                 if (Yii::$app->getUser()->login($user)) {
                     return $this->goHome();
                 }
             }
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:15,代码来源:SiteController.php


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