profileQuery = $profileQuery; parent::__construct($id, $module, $config); } /** * @inheritdoc */ public function behaviors() { return [ 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'actions' => ['index'], 'roles' => ['@'] ], [ 'allow' => true, 'actions' => ['show'], 'roles' => ['?', '@'] ], ], ], ]; } public function actionIndex() { return $this->redirect(['show', 'id' => Yii::$app->user->getId()]); } public function actionShow($id) { $profile = $this->profileQuery->whereId($id)->one(); if ($profile === null) { throw new NotFoundHttpException(); } return $this->render( 'show', [ 'profile' => $profile, ] ); } }