Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for request parameter transformations #1

Open
corazzi opened this issue Apr 27, 2017 · 0 comments
Open

Allow for request parameter transformations #1

corazzi opened this issue Apr 27, 2017 · 0 comments

Comments

@corazzi
Copy link
Owner

corazzi commented Apr 27, 2017

Different forms may make requests with different request parameters for the same data.

For example, one form may send a parameter of minDateand another form may send a parameter of minimumDate, but both need to map to the filterMinimumDate() method.

A $transforms property could look like this:

protected $transforms = [
    'minDate' => 'minimumDate'
];

The resolver will call a performTransformations() method before running each mapped filter which will set a request parameter of minimumDate to be the value of the existing request parameter minDate.

protected $map = [
    'minimumDate' => 'filterMinimumDate',
]

protected $transforms = [
    'minDate' => 'minimumDate',
    'dateMin' => 'minimumDate',
    'fromDate' => 'minimumDate',
];

Now it won't matter if the form sends minDate, dateMin, fromDate, or mimimumDate – it will always be mapped to the filterMinimumDate method.

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

No branches or pull requests

1 participant