/** * Initializes the module. * * This method is called after the module is created and initialized with property values * given in configuration. The default implementation will initialize [[controllerNamespace]] * if it is not set. * * If you override this method, please make sure you call the parent implementation. */ public function init() { if ($this->userIdentityClass === null) { $this->userIdentityClass = Yii::$app->getUser()->identityClass; } if ($this->commentModelClass === null) { $this->commentModelClass = CommentModel::className(); } parent::init(); }
/** * Declares external actions for the controller. * * @return array */ public function actions() { return ['edit-comment' => ['class' => EditableAction::className(), 'modelClass' => CommentModel::className(), 'forceCreate' => false]]; }
/** * Finds the CommentModel model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CommentModel the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CommentModel::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Returns the validation rules for attributes. * @return array validation rules */ public function rules() { return ArrayHelper::merge([[['id', 'createdBy', 'content', 'status', 'relatedTo'], 'safe']], parent::rules()); }