You are here

class OffsetPage in JSON:API 8

Same name and namespace in other branches
  1. 8.2 src/Query/OffsetPage.php \Drupal\jsonapi\Query\OffsetPage

Value object for containing the requested offset and page parameters.

@internal

Hierarchy

Expanded class hierarchy of OffsetPage

9 files declare their use of OffsetPage
EntityResource.php in src/Controller/EntityResource.php
EntityResourceTest.php in tests/src/Kernel/Controller/EntityResourceTest.php
JsonApiFunctionalTest.php in tests/src/Functional/JsonApiFunctionalTest.php
JsonApiParamEnhancer.php in src/Routing/JsonApiParamEnhancer.php
JsonApiParamEnhancerTest.php in tests/src/Unit/Routing/JsonApiParamEnhancerTest.php

... See full list

File

src/Query/OffsetPage.php, line 10

Namespace

Drupal\jsonapi\Query
View source
class OffsetPage {

  /**
   * The JSON API pagination key name.
   *
   * @var string
   */
  const KEY_NAME = 'page';

  /**
   * The offset key in the page parameter: page[offset].
   *
   * @var string
   */
  const OFFSET_KEY = 'offset';

  /**
   * The size key in the page parameter: page[limit].
   *
   * @var string
   */
  const SIZE_KEY = 'limit';

  /**
   * Default offset.
   *
   * @var int
   */
  const DEFAULT_OFFSET = 0;

  /**
   * Max size.
   *
   * @var int
   */
  const SIZE_MAX = 50;

  /**
   * The offset for the query.
   *
   * @var int
   */
  protected $offset;

  /**
   * The size of the query.
   *
   * @var int
   */
  protected $size;

  /**
   * Instantiates an OffsetPage object.
   *
   * @param int $offset
   *   The query offset.
   * @param int $size
   *   The query size limit.
   */
  public function __construct($offset, $size) {
    $this->offset = $offset;
    $this->size = $size;
  }

  /**
   * Returns the current offset.
   *
   * @return int
   *   The query offset.
   */
  public function getOffset() {
    return $this->offset;
  }

  /**
   * Returns the page size.
   *
   * @return int
   *   The requested size of the query result.
   */
  public function getSize() {
    return $this->size;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OffsetPage::$offset protected property The offset for the query.
OffsetPage::$size protected property The size of the query.
OffsetPage::DEFAULT_OFFSET constant Default offset.
OffsetPage::getOffset public function Returns the current offset.
OffsetPage::getSize public function Returns the page size.
OffsetPage::KEY_NAME constant The JSON API pagination key name.
OffsetPage::OFFSET_KEY constant The offset key in the page parameter: page[offset].
OffsetPage::SIZE_KEY constant The size key in the page parameter: page[limit].
OffsetPage::SIZE_MAX constant Max size.
OffsetPage::__construct public function Instantiates an OffsetPage object.