Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Extend RouteBasedCollectionStrategy #47

Open
marcosh opened this issue Oct 18, 2018 · 1 comment
Open

Extend RouteBasedCollectionStrategy #47

marcosh opened this issue Oct 18, 2018 · 1 comment

Comments

@marcosh
Copy link
Contributor

marcosh commented Oct 18, 2018

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

@weierophinney
Copy link
Member

This repository has been closed and moved to mezzio/mezzio-hal; a new issue has been opened at mezzio/mezzio-hal#5.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants