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

Commit e1fee85

Browse files
committed
Expose as a standalone component / module
- Added a `ConfigProvider`, for exposing the `FilterManager` service. - Added a `Module`, for providing zend-mvc with configuration, and notifying the service listener of the filter provider specification. - Updated `composer.json` to expose a comonent and config-provider.
1 parent c42042f commit e1fee85

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
"branch-alias": {
3737
"dev-master": "2.6-dev",
3838
"dev-develop": "2.7-dev"
39+
},
40+
"zf": {
41+
"component": "Zend\\Filter",
42+
"config-provider": "Zend\\Filter\\ConfigProvider"
3943
}
4044
},
4145
"autoload-dev": {

src/ConfigProvider.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
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
6+
*/
7+
8+
namespace Zend\Filter;
9+
10+
class ConfigProvider
11+
{
12+
/**
13+
* Return configuration for this component.
14+
*
15+
* @return array
16+
*/
17+
public function __invoke()
18+
{
19+
return [
20+
'dependencies' => $this->getDependencyConfig(),
21+
];
22+
}
23+
24+
/**
25+
* Return dependency mappings for this component.
26+
*
27+
* @return array
28+
*/
29+
public function getDependencyConfig()
30+
{
31+
return [
32+
'factories' => [
33+
'FilterManager' => FilterPluginManagerFactory::class,
34+
],
35+
];
36+
}
37+
}

src/Module.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
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
6+
*/
7+
8+
namespace Zend\Filter;
9+
10+
class Module
11+
{
12+
/**
13+
* Return default zend-filter configuration for zend-mvc applications.
14+
*/
15+
public function getConfig()
16+
{
17+
$provider = new ConfigProvider();
18+
19+
return [
20+
'service_manager' => $provider->getDependencyConfig(),
21+
];
22+
}
23+
24+
/**
25+
* Register a specification for the FilterManager with the ServiceListener.
26+
*
27+
* @param \Zend\ModuleManager\ModuleEvent
28+
* @return void
29+
*/
30+
public function init($event)
31+
{
32+
$container = $event->getParam('ServiceManager');
33+
$serviceListener = $container->get('ServiceListener');
34+
35+
$serviceListener->addServiceManager(
36+
'FilterManager',
37+
'filters',
38+
'Zend\ModuleManager\Feature\FilterProviderInterface',
39+
'getFilterConfig'
40+
);
41+
}
42+
}

0 commit comments

Comments
 (0)