yiisoft / data

Data providers

Home Page:https://www.yiiframework.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove `PaginatorInterface`

vjik opened this issue · comments

Implementations of PaginatorInterface is very different. Some methods need in one implementation, and not need in other implementations. Some methods should named different in different implementations. Seems PaginatorInterface not need.

For example, KeysetPaginator contains methods withNextPageToken(string $token) and withPreviousPageToken(string $token), but in OffsetPaginator instead this methods need one method withCurrentPage(int $page).

Yii Data depended packages:

  • yiisoft/data-db,
  • yiisoft/yii-cycle,
  • yiisoft/app-api,
  • yiisoft/demo,
  • yiisoft/yii-dataview.

But PaginatorInterface used in yiisoft/yii-dataview only. In class BaseListView user may set paginator via method paginator(PaginatorInterface $value), but into class code used implementations KeysetPaginator and OffsetPaginator, and pass custom implementation of PaginatorInterface throws error or will be work incorrect, for example, here:

private function renderSummary(): string
{
	if ($this->getPaginator() instanceof KeysetPaginator) {
		return '';
	}

	$pageCount = count($this->getDataReader());

	if ($pageCount <= 0) {
		return '';
	}

	/** @var OffsetPaginator $paginator */
	$paginator = $this->getPaginator();
	
	// ...

Likely you are correct. There's no common in these two paginators and there could not be a common usage among them.

Decided with team not implement this concept.