本文整理匯總了PHP中dektrium\user\Finder::findAccountById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Finder::findAccountById方法的具體用法?PHP Finder::findAccountById怎麽用?PHP Finder::findAccountById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dektrium\user\Finder
的用法示例。
在下文中一共展示了Finder::findAccountById方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionConnect
/**
* Displays page where user can create new account that will be connected to social account.
* @param integer $account_id
* @return string
* @throws NotFoundHttpException
*/
public function actionConnect($account_id)
{
$account = $this->finder->findAccountById($account_id);
if ($account === null || $account->getIsConnected()) {
throw new NotFoundHttpException();
}
/** @var User $user */
$user = \Yii::createObject(['class' => User::className(), 'scenario' => 'connect']);
if ($user->load(\Yii::$app->request->post()) && $user->create()) {
$account->link('user', $user);
\Yii::$app->user->login($user, $this->module->rememberFor);
return $this->goBack();
}
return $this->render('connect', ['model' => $user, 'account' => $account]);
}
示例2: actionDisconnect
/**
* Disconnects a network account from user.
* @param integer $id
* @return \yii\web\Response
* @throws \yii\web\NotFoundHttpException
* @throws \yii\web\ForbiddenHttpException
*/
public function actionDisconnect($id)
{
$account = $this->finder->findAccountById($id);
if ($account === null) {
throw new NotFoundHttpException();
}
if ($account->user_id != \Yii::$app->user->id) {
throw new ForbiddenHttpException();
}
$account->delete();
return $this->redirect(['networks']);
}