Closed vaclavvanik closed 5 years ago
@weierophinney do you think it is a bug? Should I create PR?
@vaclavvanik Please look at:
...and you will find input_filters
.
Or do you try to add the entire specification as array in the configuration and not the factories?
Doesn't it say the problem right here:
Plugin of type MyInput is invalid; must implement Zend\InputFilter\InputFilterInterface or Zend\InputFilter\InputInterface
your MyInput
class does not implement those interfaces or extend other class that does
@Xerkus
I think @vaclavvanik wants to insert the input-filter specification as an array into the configuration and for this the InputFilterAbstractFactory
must be added manually as described in the documentation:
Setup
When using zend-mvc version 2 releases, this functionality is disabled by default. To enable it, you must add the
Zend\InputFilter\InputFilterAbstractServiceFactory
abstract factory to theZend\InputFilter\InputFilterPluginManager
configuration, which is under theinput_filters
configuration key.
https://docs.zendframework.com/zend-inputfilter/specs/#setup
@froschdesign I see, $autoAddInvokableClass = true
masked the problem.
@froschdesign as I wrote above I think, that it is a bug, that in Module.php
is missing config line with input_filters
. Which causes that InputFilterAbstractFactory
is not registered in InputFilterPluginManager
.
In ConfigProvider is InputFilterAbstractFactory
registered.
@vaclavvanik Did you see the hint in the documentation?
In the docs is:
For Expressive when using the configuration manager, and for zend-mvc v3 releases, the functionality is enabled by default, assuming you are using the component installer.
I am using mvc v3 and InputFilterAbstractFactory
is not registered... :-/
Just checked, docs are indeed wrong. It is not registered for any mvc version by default. Are there any reasons why we wouldn't want to enable it by default for mvc as well?
@vaclavvanik
I'm confused, unfortunately. If you use version v3 then you should have also the last version of zend-inputfilter! And the latest of version of zend-inputfilter contains the InputFilterAbstractFactory
!
Or I'm wrong?
@vaclavvanik I will create a pull request when I'm back on my computer and will ping you for testing.
@froschdesign #162 fixed InputFilterAbstractFactory
registration in ConfigProvider
(Expressive). MVC v3 uses Module
and in this class has not 'input_filters' config key in getConfig()
which causes that InputFilterAbstractFactory
is not registered... (really confusing)
@vaclavvanik
really confusing
Right, because in zend-form is the behaviour different. :confused:
InputFilterPluginManager in MVC environment does not create input filter defined in config.
Code to reproduce the issue
Expected results
InputFilterPluginManager creates defined InputFilter
Actual results
Exception thrown
Imho this happens because Module.php provide incomplete config.