Empty pagination after post request

For programming and general questions on Zend Framework

Empty pagination after post request

Postby kay1818 on Sun Oct 15, 2017 10:50 pm

I built a rest api using zf-rest. I want to send data via post. The api should make a database call with the posted data and answer with a collection of hal entities wrapped by a paginator:

public function create($data) {
  $inputFilter = $this->getInputFilter();

  /** @type ZF\Hal\Entity[] $result */
  $result = $database->select($inputFilter);

  return Zend\Paginator\Paginator(new ResultAdapter($result, count($result));
}

class ResultAdapter implements AdapterInterface {
  protected $data = null;
  protected $resultCount = null;

  public function __construct(array $data = [], $resultCount = 0) {
    $this->data = $data;
    $this->resultCount = $resultCount;
  }

  public function getItems($offset, $itemCountPerPage) {
   return $this->data;
}

  public function count() {
    return $this->resultCount;
  }
}

I checked the result variable and it is an array with the correct output (about 1000 elements).
But everything I will get from the api is an empty paginator json:

{"adapters":null,"config":null,"defaultScrollingStyle":"Sliding","defaultItemCountPerPage":10,"scrollingStyles":null,"cache":null,"cacheEnabled":true,"adapter":{},"currentItemCount":null,"currentItems":null,"currentPageNumber":1,"filter":null,"itemCountPerPage":null,"pageCount":null,"pageRange":10,"pages":null,"view":null,"_links":{"self":{"href":"\/api\/rest\/search-request"}}}

Is there a special config I have to set or is my return wrong?
kay1818
 
Posts: 1
Joined: Sun Oct 15, 2017 10:33 pm

Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 4 guests

cron