コード例 #1
0
ファイル: PostController.php プロジェクト: tampaphp/app-cms
 /**
  * Lists all Post models on specific post type.
  * If there is user, the action will generate list of all Post models based on user.
  *
  * @param integer     $post_type
  * @param null|string $user
  *
  * @throws \yii\web\ForbiddenHttpException
  * @throws \yii\web\NotFoundHttpException
  * @return mixed
  */
 public function actionIndex($post_type, $user = null)
 {
     $postType = $this->findPostType($post_type);
     $searchModel = new PostSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $post_type, $user);
     if (!Yii::$app->user->can($postType->post_type_permission)) {
         throw new ForbiddenHttpException(Yii::t('writesdown', 'You are not allowed to perform this action.'));
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'postType' => $postType, 'user' => $user]);
 }
コード例 #2
0
ファイル: PostController.php プロジェクト: hdushku/npai
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new PostSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }