Description
Hi,
I have provided a resource adapter with the following default pagination parameters:
protected $defaultPagination = [ 'size' => 5, 'number' => 2 ];
,
however I still got the default laravel "current-page": 1,"per-page": 15 pagination (with no explicitely requested pagination parameters in the URI), so I delved a bit into the code and it seems that the defaultPagination is disregarded in the last line of the EloquentAdapter's query() method
return $pagination->isEmpty() ? $this->all($query) : $this->paginate($query, $parameters);
$pagination gets either the parameters provided in the query string, or (if none are provided) the $defaultPagination, however after it is checked for being empty, the paginate() method still receives the query string $parameters instead of the $pagination.
I guess the easiest and backward-compatible fix would be to create a new instance of EncodingParameters where $pagination is passed for pagination parameters and the rest params are copied from the original $parameters (rather than modifying the paginate() methods of the EloquentAdapter and the PagingStrategyInterface to receive an array as a second parameter). I am not sure for the case where for example only page[size] has been specified - if $pagination['number'] should not be taken as a default. If so, some more checks have to be added as well in the query() or extractPagination() method.