-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove getPaginator() from PaginatorInterface #101
Conversation
…uch as query/appends) to be ignored. Refactored paginator tests.
@garygreen said:
Suppose the following class <?php
use League\Fractal\Pagination\PaginatorInterface;
class MyOwnPaginator implements PaginatorInterface
{
/*
public function getCurrentPage();
public function getLastPage();
public function getTotal();
public function getCount();
public function getPerPage();
public function getUrl($page);
*/
public function getPaginator()
{
// ???
// return $this;
}
} Without an underlying paginator what should I think the interface should only care about methods that are used in fractal and not in other libraries. |
Fair point. It's possibly a good idea to remove it from the interface, as it does depend on how you construct the adapter but it depends on if people see a value in calling/accessing the underlying paginator -- It was added because this is merely an 'adapter' class and wasn't really intended to be the 'real' paginator instance. It's kinda strange to have your paginator built directly off the fractal paginator adapter interface if I'm honest (I really don't think it was designed with that in mind). I would have thought you would structure it like this:
|
A few more things to consider;
I think the whole confusion springs from how you're building directly off the adapter interace, which I would strongly recommend against for the above reasons. |
I'm aware of loose coupling and in fact I have an underlying paginator. But I think it isn't the task of fractal to guarantee the building of a loosely coupled adapter. This is part of the application architecture and should be in responsibility of the developer. |
Another example: I have implemented |
Not entirely sure why that was ever there. Paginator interface changed a few times so it was probably useful at one point. The tests still pass so whatever. |
Thanks |
What is the need and the output of the method
PaginatorInterface::getPaginator()
? I couldn't find any use or tests for this method. But I have to declare it in my Paginator? Why should a Paginator return itself?There might be a need for this method in IlluminatePaginatorAdapter, but not in the Interface.