Pagination in Entity List

Created on 13 May 2020, about 4 years ago
Updated 10 March 2024, 4 months ago

Hi,

Can you please explain how the pager works, in combination ExternalEntityListBuilder and the API calls (also the count() call).

As far as I can see, the value set in the Storage Client > Default number of items per page, is really the *max* number of total items that the ExternalEntityListBuilder can list, and the hardcoded pager value of 50 (set in load()) is the actual number of items per page 'if' it is below 'Default number of items per page'.

I understand that the ExternalEntityListBuilder is not a full blown infinate views table, which when linked to wikipedia would have a million pages, but the default settings and/or field lables don't seem to make sense to me.

I have a working setup. In my rest API I have 100 items. I want to set the default items per page to 10, and get 10 pages.
But this is not possible.

What is the rationale here and how is it supposed to work - or is it just for demonstrative/getting started purposes ?

Thanks :)

πŸ’¬ Support request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom 8bitplateau

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Merge request !37Resolve #3136353 "Pagination in entity" β†’ (Open) created by guignonv
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update 4 months ago
    2 pass
  • Status changed to Needs review 4 months ago
  • πŸ‡«πŸ‡·France guignonv

    The default Drupal behavior is to list 50 entities per page (@see Drupal\Core\Entity\EntityListBuilder protected $limit = 50;). Currently, that value is hard coded in ExternalEntityListBuilder and ExternalEntityTypeListBuilder but it should rely on the inherited property (as proposed in the PR). It has nothing to deal with the default REST plugin pagination limit also set to 50 which sits there for another purpose (even if still, it's for a page limitation).

    If you look at the REST storage client implementation, getPagingQueryParameters() sets the limit to the $length variable if it is set and fallbacks to the default limit given in the storage client config. Therefore, you could set a default value of 100 in the storage client, it would not change the number of external entities displayed on the listing page as the limit value comes from Drupal entity listing system itself. The default limit provided by the storage client config is there when the client is called by other applications in other modules if the caller forgot to give a length limit. It avoids querying too many entities from the remote source at once, which may not work.

    However, we could argue that there should be a "hard limit" setting in the REST client because some REST services may force a limitation (ie. you ask 50 elements but the server only allows 10 at once for instance). Then, that limit should be taken into account by the storage client when getPagingQueryParameters() is called with a $length larger than that hard limit: the client would have to call the remote source several times with the lower limit to fulfill the requested number of items. But that's a different issue which should be a feature request. Feel free to submit it...

Production build 0.69.0 2024