當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。