data
data copied to clipboard
Refactor Model::getFields
- Introduce constants to declare Model field filter presets
- Adds
Model::FIELD_FILTER_PERSIST
filter preset - Adds
Model::FIELD_FILTER_ONLY_FIELDS
filter preset - uses new presets to remove duplicate code
- Provide the possibility to filter fields by Closure
Provides possibility to filter fields by Closure
I do not get this - we should get all and filter then, what is the advantage of your approach?
This is also true. Main point was to introduce the 'persisting' preset to avoid duplicate code. And streamline the code a bit with the ifs and buts. Passing a Closure as filter is a side-effect
I have another idea: Presently filters are in first argument as array and considered OR.
We can introduce multiple arguments which will be filters merged with AND.
So $model->getFields('system', 'only_fields')
will return fields system AND only fields
So $model->getFields(['system', 'only_fields'])
will return fields system OR only fields
It will not be BC though I believe.
I have another idea: Presently filters are in first argument as array and considered OR.
I like minimalistic APIs. We extend Model more and more for BC... And the questions is what this more and more code provides? Does it really help and reduce the maintanence requirements? If yes, go ahead!
TODO rebase on develop, it is based on https://github.com/atk4/data/pull/690, only the last 10 commits are relevant (others are from the mentioned PR) - https://github.com/atk4/data/compare/be3cb50a37...d6307b30c3