Pagerfanta icon indicating copy to clipboard operation
Pagerfanta copied to clipboard

Can't Add "All" option

Open sidz opened this issue 10 years ago • 3 comments

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.

sidz avatar Jan 13 '15 08:01 sidz

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

stof avatar Jan 13 '15 08:01 stof

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.

sidz avatar Jan 13 '15 08:01 sidz

@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

stof avatar Jan 13 '15 14:01 stof