Sets the pagination for this data provider.
public setPagination ( array | |
||
$value | array | |
the pagination to be used by this data provider. This can be one of the following: - a configuration array for creating the pagination object. The "class" element defaults to 'yii\data\Pagination' - an instance of [[Pagination]] or its subclass - false, if pagination needs to be disabled. |
/** * Constructor. * @param BaseDataProvider $dataProvider the data provider to iterate over * @param integer $pageSize pageSize to use for iteration. This is the number of objects loaded into memory at the same time. */ public function __construct(BaseDataProvider $dataProvider, $pageSize = null) { $this->_dataProvider = $dataProvider; $this->_totalItemCount = $dataProvider->getTotalCount(); if (($pagination = $this->_dataProvider->getPagination()) === false) { $this->_dataProvider->setPagination($pagination = new Pagination()); } if ($pageSize !== null) { $pagination->pageSize = $pageSize; } }
/** * Sets the pagination for this data provider. * @param array|Pagination|boolean $value The pagination to be used by this data provider. * This can be one of the following: * * - a configuration array for creating the pagination object. The "class" element defaults * to 'UrbanIndo\Yii2\DynamoDb\Pagination' * - an instance of [[Pagination]] or its subclass * - false, if pagination needs to be disabled. * * @throws InvalidParamException When the value is not Pagination instance. * @return void */ public function setPagination($value) { if (is_array($value)) { $config = ['class' => Pagination::className()]; if ($this->id !== null) { $config['pageSizeParam'] = $this->id . '-per-page'; } parent::setPagination(Yii::createObject(array_merge($config, $value))); } elseif ($value instanceof Pagination || $value === false) { parent::setPagination($value); } else { throw new InvalidParamException('Only Pagination instance, configuration array or false is allowed.'); } }