无法在Yi2 rest或activeDataProvider中设置页面大小限制

无法在Yi2 rest或activeDataProvider中设置页面大小限制,rest,yii,pagination,yii2,yii-rest,Rest,Yii,Pagination,Yii2,Yii Rest,我无法在rest应用程序中设置ActiveDataProvider(分页)pageSize的值 以更改每页中的项目。 这是我在controller中的示例代码 class EndpointController extends ActiveController { public $modelClass = 'common\models\Endpoint'; // public $serializer = [ // 'class' => 'yii\rest\Serial

我无法在rest应用程序中设置ActiveDataProvider(分页)pageSize的值 以更改每页中的项目。 这是我在controller中的示例代码

class EndpointController extends ActiveController
{
public $modelClass = 'common\models\Endpoint';
//     public $serializer = [
//         'class' => 'yii\rest\Serializer',
//         'collectionEnvelope' => 'items',
    // //         'metaEnvelope' => false
//     ];
public function init()
{
    parent::init();
    \Yii::$app->user->enableSession = false;
    \Yii::$app->user->loginUrl = null;
}
public function behaviors()
{
    $behaviors = parent::behaviors();
    $behaviors['authenticator'] = [
        'class' => QueryParamAuth::className(),
        'tokenParam' => 'access_token',
    ];
    return $behaviors;
}
protected function verbs()
{
    $verbs = parent::verbs();
    unset($verbs['update'], $verbs['create'], $verbs['delete'],         $verbs['view'], $verbs['index'][1]);
//         $verbs['index'][] = 'POST';
    return $verbs;
}

public function actions()
{
    $actions = parent::actions();
    unset($actions['update'], $actions['create'], $actions['delete'], $actions['view'], $actions['options']);
    return $actions;
}
public function prepareDataProvider()
{
//         $activData = new ActiveDataProvider([
//             'query' => Endpoint::find(),
//             'pagination' => [
//                 'pageSize' => 2,
//             ]
//         ]);
//         return $activData;
}

public function actionIndex()
{
//         $activData = new ActiveDataProvider([
//             'query' => Endpoint::find(),
//             'pagination' => [
//                 'pageSize' => 2,
//             ]
//         ]);
    //         return $activData;
}    
}

我的模型有基本的模板,我以前在互联网上测试过所有的解决方案,但没有效果

我通过答案找到了解决方案
你是什么意思?您的相关代码已被注释…@scaisEdge我注释了此代码,表示我以前测试过此解决方案。似乎您已经找到了解决方案。。好。。