Skip to content
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
@ffraenz

Description

@ffraenz

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions