* @copyright (c), Thread */ class OwnprofileController extends BackendController { public $name = 'ownprofile'; public $title = "Profile"; protected $model = Profile::class; public $defaultAction = 'update'; public $actionListLinkStatus = ['/user/user/list']; /** * @return mixed * @throws NotFoundHttpException * @throws \Exception */ public function init() { if (Yii::$app->getRequest()->get('id') != Yii::$app->getUser()->id) { throw new NotFoundHttpException(); } return parent::init(); } /** * * @return array */ public function actions() { $model = Profile::findByUserId(Yii::$app->getUser()->id); $user = $model->user; return [ 'update' => [ 'class' => Update::class, 'modelClass' => $this->model, 'redirect' => function () { return $_POST['save_and_exit'] ? ['/user/user/list'] : ['update', 'id' => $this->action->getModel()->id]; } ], 'fileupload' => [ 'class' => UploadAction::class, 'path' => $this->module->getAvatarUploadPath($user) ], 'filedelete' => [ 'class' => DeleteAction::class, 'path' => $this->module->getAvatarUploadPath($user) ], ]; } }