/**
  * Sets the pagination for this data provider.
  * @param array|Pagination|boolean $value The pagination to be used by this data provider.
  * This can be one of the following:
  *
  * - a configuration array for creating the pagination object. The "class" element defaults
  *   to 'UrbanIndo\Yii2\DynamoDb\Pagination'
  * - an instance of [[Pagination]] or its subclass
  * - false, if pagination needs to be disabled.
  *
  * @throws InvalidParamException When the value is not Pagination instance.
  * @return void
  */
 public function setPagination($value)
 {
     if (is_array($value)) {
         $config = ['class' => Pagination::className()];
         if ($this->id !== null) {
             $config['pageSizeParam'] = $this->id . '-per-page';
         }
         parent::setPagination(Yii::createObject(array_merge($config, $value)));
     } elseif ($value instanceof Pagination || $value === false) {
         parent::setPagination($value);
     } else {
         throw new InvalidParamException('Only Pagination instance, configuration array or false is allowed.');
     }
 }
Пример #2
0
 /**
  * @dataProvider dataProviderGetLinks
  *
  * @param string|string[] $currentLastKey The current last key.
  * @param string|string[] $nextLastKey    The next last key.
  * @param integer         $pageSize       The page size to show.
  * @param array           $links          The links resulted
  */
 public function testGetLinks($currentLastKey, $nextLastKey, $pageSize, $links)
 {
     $pagination = new Pagination(['route' => 'item/list', 'lastKey' => $currentLastKey, 'nextLastKey' => $nextLastKey, 'pageSize' => $pageSize]);
     $this->assertEquals($links, $pagination->getLinks());
 }