getPagination() public method

public getPagination ( ) : Pagination
return Pagination the pagination object. If this is false, it means the pagination is disabled.
Beispiel #1
0
 /**
  * Serializes a data provider.
  * @param DataProviderInterface $dataProvider
  * @return array the array representation of the data provider.
  */
 protected function serializeDataProvider($dataProvider)
 {
     $models = $this->serializeModels($dataProvider->getModels());
     if ($dataProvider->getPagination() === false) {
         return $models;
     } else {
         return ['total' => $dataProvider->getTotalCount(), 'rows' => $models];
     }
 }
Beispiel #2
0
 /**
  * Serializes a data provider.
  * @param DataProviderInterface $dataProvider
  * @return array the array representation of the data provider.
  */
 protected function serializeDataProvider($dataProvider)
 {
     $models = $this->serializeModels($dataProvider->getModels());
     if (($pagination = $dataProvider->getPagination()) !== false) {
         $this->addPaginationHeaders($pagination);
     }
     if ($this->request->getIsHead()) {
         return null;
     } elseif ($this->collectionEnvelope === null) {
         return $models;
     } else {
         $result = [$this->collectionEnvelope => $models];
         if ($pagination !== false) {
             return array_merge($result, $this->serializePagination($pagination));
         } else {
             return $result;
         }
     }
 }
Beispiel #3
0
 /**
  * Serializes a data provider.
  * @param DataProviderInterface $dataProvider
  * @return array the array representation of the data provider.
  */
 protected function serializeDataProvider($dataProvider)
 {
     $models = $this->serializeModels($dataProvider->getModels());
     if (($pagination = $dataProvider->getPagination()) !== false) {
         $this->addPaginationHeaders($pagination);
     }
     if ($this->request->getIsHead()) {
         return null;
     } elseif ($this->collectionEnvelope === null) {
         return $models;
     } else {
         $result = ['success' => 1, 'message' => \Yii::$app->response->statusText, 'status' => \Yii::$app->response->getStatusCode(), $this->collectionEnvelope => $models];
         if ($pagination !== false) {
             return array_merge($result, $this->serializePagination($pagination));
         } else {
             return $result;
         }
     }
 }
Beispiel #4
0
 /**
  * Serializes a data provider.
  * @param DataProviderInterface $dataProvider
  * @return array the array representation of the data provider.
  */
 protected function serializeDataProvider($dataProvider)
 {
     if ($this->request->getIsHead()) {
         return null;
     } else {
         $models = [];
         $includedModels = [];
         foreach ($dataProvider->getModels() as $model) {
             if ($model instanceof ResourceInterface) {
                 $models[] = $this->serializeModel($model);
                 $included = $this->serializeIncluded($model);
                 foreach ($included as $document) {
                     $includedModels[] = $document;
                 }
             }
         }
         $result = ['data' => $models];
         if (!empty($includedModels)) {
             $result['included'] = $includedModels;
         }
         if (($pagination = $dataProvider->getPagination()) !== false) {
             return array_merge($result, $this->serializePagination($pagination));
         }
         return $result;
     }
 }