This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
Input Filter Factory uses a different FilterPluginManager instance #79
Closed
Description
I created a custom filter which needs dependency injection by a factory. I added the filter to the config array like so:
return [
'filters' => [
'factories' => [
'ToFile' => 'Module\Factory\Filter\ToFile',
],
],
];
I am able to get a filter instance from the FilterPluginManager
inside a controller:
$filter = $this->getServiceLocator()->get('FilterManager')->get('ToFile');
var_dump($filter);
Inside the init()
method of a class extending Zend\Form\Form
I configured an input filter using the custom filter. The form also uses custom form elements from the FormElementManager
.
$this->getInputFilter()->add([
'name' => 'file',
'required' => false,
'filters' => [
[ 'name' => 'ToFile' ],
],
]);
Custom form elements are working fine but the custom filter always raises a ServiceNotFoundException
:
Zend\Filter\FilterPluginManager::get was unable to fetch or create an instance for ToFile
I found out that the Input Filter Factory is using a different FilterPluginManager
instance which has never seen the config array. The custom filter with its factory is not included in the plugin manager.
This is unexpected behaviour? Or am I wrong?
Metadata
Metadata
Assignees
Labels
No labels