zend-expressive-hal icon indicating copy to clipboard operation
zend-expressive-hal copied to clipboard

Extend `RouteBasedCollectionStrategy`

Open marcosh opened this issue 7 years ago • 1 comments

I am trying to modify the default fields which appear in a collection response. In particular I'm filtering and paginating my collection and, beside _total_items I would like to have also other fields like _total_items_without_filters and _total_items_with filters_but_without_pagination.

The fact is that inside RouteBasedCollectionStrategy, the creation of the resource happens in the private method extractIterator which is called by the private method extractCollection, which requires also the presence of the method extractPaginator.

All of this said, to add a new field to the resource I must extends the RouteBasedCollectionStrategy class, copy and paste all the above mentioned methods, just to edit the line $data = ['_total_items' => $count];

It would be nice if just the creation of the $data could be exposed, at least in a protected method, so that modifying it could become easier

marcosh avatar Oct 18 '18 15:10 marcosh

This repository has been closed and moved to mezzio/mezzio-hal; a new issue has been opened at https://github.com/mezzio/mezzio-hal/issues/5.

weierophinney avatar Dec 31 '19 20:12 weierophinney