【发布时间】:2017-10-16 01:48:44
【问题描述】:
我的过滤器有以下配置。用于zend框架设置服务管理器。
$filters = [
'factories' => ['Administration\Filter\StripSpaces'=>'Zend\ServiceManager\Factory\InvokableFactory']
'aliases' => ['StripSpaces'=>'Administration\Filter\StripSpaces']
];
return ['filters'=>$filters];
表格使用
$inputFilter->add([
'name' => 'objectclassname',
'required' => true,
'filters' => [
['name' => 'StringTrim'],
['name' => 'StripTags'],
['name' => 'StripNewlines'],
['name' => 'StripSpaces'] // here is where my StripSpaces alias is used
],
'validators' => [
[
'name' => 'StringLength',
'options' => [
'min' => 5,
'max' => 255
],
]
],
]);
这是加载使用此过滤器的表单时的错误:
A plugin by the name "StripSpaces" was not found in the plugin manager Zend\Filter\FilterPluginManager
【问题讨论】:
-
@AlainPomirol 为什么我不能将它添加到服务管理器并添加别名而不是完成所有这些工作?他们希望我添加一个自定义过滤器并且他们具有相同的配置
-
您将在docs.zendframework.com/zend-filter/filter-chains/… 的文档中找到解释。
FilterPluginManager附加到每个FilterChain实例。FilterChain中使用的每个过滤器都必须为过滤器插件管理器所知。
标签: filter configuration zend-framework2 zend-framework3 zend-filter