KnpPaginatorBundle icon indicating copy to clipboard operation
KnpPaginatorBundle copied to clipboard

Add missing methods in SlidingPaginationInterface

Open sci3ma opened this issue 5 years ago • 9 comments

sci3ma avatar Jan 24 '20 09:01 sci3ma

Why such methods are supposed to be "missing"?

garak avatar Jan 24 '20 09:01 garak

Short answer: You can't find them in the interface ;)

Long answer (based on my case): I built some pageable object which serves more data (total pages, first, last, total items, next page, etc...) in rest api response. SlidingPagination provides most of these methods but:

  1. You can't mock SlidingPagination class because it's final
  2. Would be better to inject interface than base class

I wonder why not all methods are in this interface? Is there any purpose of that?

sci3ma avatar Jan 24 '20 10:01 sci3ma

Can't you use AbstractPagination or PaginationInterface instead?

garak avatar Jan 24 '20 11:01 garak

No because AbstractPagination and PaginationInterface doesn't have such methods. Like I mentioned only SlidingPagination has these methods but SlidingPaginationInterface has some lacks.

Maybe my point of view is too narrow and I don't fully understand your thoughts why SlidingPaginationInterface can't have such methods, then explain please.

sci3ma avatar Jan 24 '20 14:01 sci3ma

You can find relevant informations in issue #598 and related PR

garak avatar Jan 24 '20 14:01 garak

Thanks, but it doesn't explain why we can't add methods in SlidingPaginationInterface which are exist in SlidingPagination. SlidingPaginationInterface in not fully consistent with SlidingPagination.

sci3ma avatar Jan 24 '20 14:01 sci3ma

I guess that interface was created just with needed (e.g. actually used) methods.

garak avatar Jan 24 '20 14:01 garak

Yeah, perhaps. SlidingPagination evolved but someone forgot to update SlidingPaginationInterface and now it's time to do this.

sci3ma avatar Jan 24 '20 14:01 sci3ma

SlidingPaginationInterface had no evolution: it was created just a couple of weeks ago to solve aforementioned issue

garak avatar Jan 24 '20 14:01 garak