diff --git a/framework/data/BaseDataProvider.php b/framework/data/BaseDataProvider.php index 1ec7dda2e18..871f80515a3 100644 --- a/framework/data/BaseDataProvider.php +++ b/framework/data/BaseDataProvider.php @@ -210,16 +210,15 @@ public function getPagination() public function setPagination($value) { if (is_array($value)) { - $config = [ - 'class' => Pagination::className(), - 'totalCount' => $this->getTotalCount(), - ]; + $config = ['class' => Pagination::className()]; if ($this->id !== null) { $config['pageParam'] = $this->id . '-page'; $config['pageSizeParam'] = $this->id . '-per-page'; } - $this->_pagination = Yii::createObject(array_merge($config, $value)); - } elseif ($value instanceof Pagination || $value === false) { + $value = Yii::createObject(array_merge($config, $value)); + } + if ($value instanceof Pagination || $value === false) { + $value->totalCount = $this->getTotalCount(); $this->_pagination = $value; } else { throw new InvalidArgumentException('Only Pagination instance, configuration array or false is allowed.');