You are here

PaginationParameterFactory.php in JSON-RPC 2.x

Same filename and directory in other branches
  1. 8 src/ParameterFactory/PaginationParameterFactory.php

File

src/ParameterFactory/PaginationParameterFactory.php
View source
<?php

namespace Drupal\jsonrpc\ParameterFactory;

use Drupal\jsonrpc\ParameterDefinitionInterface;
use Shaper\Util\Context;

/**
 * A parameter factory to handle paginated responses.
 */
class PaginationParameterFactory extends ParameterFactoryBase {

  /**
   * {@inheritdoc}
   */
  public static function schema(ParameterDefinitionInterface $parameter_definition) {
    return [
      'type' => 'object',
      'properties' => [
        'limit' => [
          'type' => 'integer',
          'minimum' => 0,
        ],
        'offset' => [
          'type' => 'integer',
          'minimum' => 0,
        ],
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getOutputValidator() {

    // The input is the same as the output.
    return $this
      ->getInputValidator();
  }

  /**
   * {@inheritdoc}
   */
  protected function doTransform($data, Context $context = NULL) {
    return $data;
  }

}

Classes

Namesort descending Description
PaginationParameterFactory A parameter factory to handle paginated responses.