Closed aanyszek closed 6 years ago
There is no need to, as far as I can see. All the input comes from the jQuery plugin, and is passed to a handler automatically. If you need something to process the request, you should use DI to inject appropriate dependencies (or even parameters when needed).
Maybe there is a real use case I'm missing, could you please describe more specifically what exactly cannot be done using the current implementation.
For example: I have two very similar DataTables (e.g. one with status "active" second with status "deleted" or data for admin or regular user or all that mixed together) and i think there is no need to create separated services for both handlers. Better build one and pass some parameter to handler from controller.
In your code is only pass third parameter from "DataTables\DataTables::handle()" line 61 to "$this->services[$id]->handle($query)" line 115 in the same class.
If you need to generate different results for admin and regular user, you should inject security service and use it inside the handler.
In case of filters, like "active"/"deleted"/"both", I would use DT plugin for this. The plugin allows to add custom data to the request, so you can specify "active"/"deleted"/"both" right from the client-side. Or, implement a generic handler and then inherit few specific ones from it - one for "active", one for "deleted".
I can't see method to pass some parameters to "request handler" from controller.