Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 0fcee80

Browse files
committed
Merge branch 'feature/26-filter-provider' into develop
Close #26
2 parents 5820559 + e8c681f commit 0fcee80

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ All notable changes to this project will be documented in this file, in reverse
66

77
### Added
88

9-
- Nothing.
9+
- [#26](https://github.com/zendframework/zend-filter/pull/26) adds the interface
10+
`Zend\Filter\FilterProviderInterface`, which can be used to provide
11+
configuration for the `FilterPluginManager` via zend-mvc `Module` classes.
1012

1113
### Deprecated
1214

doc/book/intro.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,27 @@ is `My_Original_Content`.
128128
As you can see it is not always possible to get the original output by using a
129129
filter which seems to be the opposite. It depends on the filter and also on the
130130
given input.
131+
132+
## Providing filters via modules
133+
134+
If you wish to indicate that your zend-mvc module provides filters, have your
135+
`Module` class implement `Zend\Filter\FilterProviderInterface`, which defines
136+
the method:
137+
138+
```php
139+
/**
140+
* @return array
141+
*/
142+
public function getFilterConfig();
143+
```
144+
145+
The method should return an array of configuration following the
146+
[zend-servicemanager configuration format](https://docs.zendframework.com/zend-servicemanager/configuring-the-service-manager/).
147+
148+
If you are not using zend-mvc, but are using a dependency injection container
149+
(e.g., if you are using Expressive), you can also provide filters using the
150+
top-level `filters` configuration key; the value of that key should be
151+
zend-servicemanager configuration, as linked above.
152+
153+
(zend-mvc users may also provide configuration in the same way, and omit
154+
implementation of the `FilterProviderInterface`.)

src/FilterProviderInterface.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-filter for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-filter/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace Zend\Filter;
9+
10+
/**
11+
* Implement this interface within Module classes to indicate that your module
12+
* provides filter configuration for the FilterPluginManager.
13+
*/
14+
interface FilterProviderInterface
15+
{
16+
/**
17+
* Provide plugin manager configuration for filters.
18+
*
19+
* @return array
20+
*/
21+
public function getFilterConfig();
22+
}

src/Module.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
/**
3-
* @link http://github.com/zendframework/zend-filter for the canonical source repository
4-
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5-
* @license http://framework.zend.com/license/new-bsd New BSD License
3+
* @see https://github.com/zendframework/zend-filter for the canonical source repository
4+
* @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-filter/blob/master/LICENSE.md New BSD License
66
*/
77

88
namespace Zend\Filter;
@@ -36,7 +36,7 @@ public function init($moduleManager)
3636
$serviceListener->addServiceManager(
3737
'FilterManager',
3838
'filters',
39-
'Zend\ModuleManager\Feature\FilterProviderInterface',
39+
FilterProviderInterface::class,
4040
'getFilterConfig'
4141
);
4242
}

0 commit comments

Comments
 (0)