Пример #1
0
 /**
  * Enable comments for indicated extension
  *
  * @param string $name Extension name
  *
  * @return boolean Whether extension is saved or not
  */
 public static function enableExtension($name)
 {
     if (isset(self::$extensions[$name])) {
         $model = new Model();
         $model->name = self::$extensions[$name];
         return $model->save();
     }
     return false;
 }
 /**
  * Comments list page.
  */
 public function actionIndex()
 {
     $searchModel = new CommentSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->get());
     $statusArray = Comment::getStatusArray();
     $modelArray = Model::getModelArray();
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'statusArray' => $statusArray, 'modelArray' => $modelArray]);
 }
 /**
  * Find model by ID.
  *
  * @param integer|array $id Model ID
  *
  * @return \stepancher\comments\models\backend\Model Model
  *
  * @throws HttpException 404 error if model not found
  */
 protected function findModel($id)
 {
     if (is_array($id)) {
         /** @var \stepancher\comments\models\backend\Model $model */
         $model = Model::findAll($id);
     } else {
         /** @var \stepancher\comments\models\backend\Model $model */
         $model = Model::findOne($id);
     }
     if ($model !== null) {
         return $model;
     } else {
         throw new HttpException(404);
     }
 }