Skip to content
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

Can't Add "All" option #168

Open
sidz opened this issue Jan 13, 2015 · 3 comments
Open

Can't Add "All" option #168

sidz opened this issue Jan 13, 2015 · 3 comments

Comments

@sidz
Copy link

sidz commented Jan 13, 2015

Hi.

How can I add a new option "All entries" when in Pagerfanta class we have method like:

private function checkMaxPerPage($maxPerPage)
    {
        if (!is_int($maxPerPage)) {
            throw new NotIntegerMaxPerPageException();
        }

        if ($maxPerPage < 1) {
            throw new LessThan1MaxPerPageException();
        }
    }

I think, better way and good solution to change private to protected, than we can override this method to add custom logic.

Now I should check in my controller if perPage is string.

Thank You.

@stof
Copy link
Contributor

stof commented Jan 13, 2015

Well, having to check it in your code is logical. Passing a string to Pagerfanta will not work because adapters are expecting an integer

@sidz
Copy link
Author

sidz commented Jan 13, 2015

Yes, I saw your code. But I think it will be better way when I can override method. Or, maybe, you can use smth like -1 option.

when i set -1 pagerfanta setMaxPerPage to nbResults or smth else.

Thank You.

@stof
Copy link
Contributor

stof commented Jan 13, 2015

@sidz this would mean that adapters would know about this special value in their implementation, which is not the case. So even if you overwrite the Pagerfanta method, you would still be breaking the Pagerfanta contract for adapters, thus breaking them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants