Client side 

By default client can only choose the page number. Two more options can be opened to the client per resource (or globally):

  • pagination_client_enabled - client can enable or disable pagination by sending ?pagination=1 or ?pagination=0 (param name can be changed with enabled_parameter_name). If the param is not sent, pagination_enabled setting decides.
  • pagination_client_items_per_page - client can change number of items per page by sending ?itemsPerPage=<int> (param name can be changed with items_per_page_parameter_name).
use SourceBroker\T3api\Annotation as T3api;

/**
 * @T3api\ApiResource(
 *     collectionOperations={
 *          "get"={
 *              "path"="/news/news",
 *          },
 *     },
 *     attributes={
 *          "pagination_client_enabled"=true,
 *          "pagination_client_items_per_page"=true,
 *          "maximum_items_per_page"=100,
 *     }
 * )
 */
class News extends \GeorgRinger\News\Domain\Model\News
{
}
Copied!

Number of items per page has to be an integer greater than or equal to 0, otherwise 400 Bad Request is returned. ?itemsPerPage=0 returns no items, only hydra:totalItems - useful when the client needs only the number of all items. It can not be combined with a page greater than 1.