A few notes from my personal gripes about what InputFilter is and does.
InputFilteris a terrible name as the class mixes sanitation and validation. Rename to something far more appropriate (e.g.InputManager?).- Data should only be processed, not stored - remove
setData()
For example, if both raw and sanitized data are required:
$sanitizedData = $this->inputManager->sanitize($data->toArray());
$validationResult = $this->inputManager->validate($sanitizedData);
if ($validationResult->isValid()) {
// hooray!
} else {
$messages = $validationResult->getMessages();
}Also, if all we need is the result:
$validationResult = $this->inputManager->sanitizeAndValidate($data->toArray());
if ($validationResult->isValid()) {
// hooray!
} else {
$messages = $validationResult->getMessages();
}
Yes, I'm very on names too. Concerning moving it to ZF-Commons, no way, Input filter is one of the most basic component and is used by various other components. This is to me a vital component, should be in core.
For InputManager, I want to homogeneize eveyrhting to using the "PluginManager" suffix. So HydratorPluginManager, InputFilterPluginManager, ControllerPluginManager… Currently the naming is not coherent (for instance the plugin manager for controllers is called ControllerLoaderManager iirc).
I'm not sure to completely grasp what you are looking for. This makes it much more complicated. If I understand correctly, you'd like the core to have only interfaces and having another library that will be aware of validation and filter ? I'm against it. Really, while modules are a great features, they SHOULD NOT be used at the expense of simplicity. If someone need to install 20 modules just to have basic functionality like input filtering, that's a no-go. Please consider that 90% of users of ZF 2 are not power-users, yet they are the ones that make ZF2 live and be a success (or not).
Going too convoluted is something really I don't want.
Anyway, I think we should speak on the PR please, I'm pretty sure most people won't get there.