Permalink
Browse files

Add MVC service factories for Filters and Validators

  • Loading branch information...
1 parent 2db58cf commit bb80dd324e454c0cbf6b5ef8dd3d85ab9d2dede9 @cgmartin cgmartin committed Sep 7, 2012
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_ModuleManager
+ */
+
+namespace Zend\ModuleManager\Feature;
+
+/**
+ * @category Zend
+ * @package Zend_ModuleManager
+ * @subpackage Feature
+ */
+interface FilterProviderInterface
+{
+ /**
+ * Expected to return \Zend\ServiceManager\Config object or array to
+ * seed such an object.
+ *
+ * @return array|\Zend\ServiceManager\Config
+ */
+ public function getFilterConfig();
+}
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_ModuleManager
+ */
+
+namespace Zend\ModuleManager\Feature;
+
+/**
+ * @category Zend
+ * @package Zend_ModuleManager
+ * @subpackage Feature
+ */
+interface ValidatorProviderInterface
+{
+ /**
+ * Expected to return \Zend\ServiceManager\Config object or array to
+ * seed such an object.
+ *
+ * @return array|\Zend\ServiceManager\Config
+ */
+ public function getValidatorConfig();
+}
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
+
+namespace Zend\Mvc\Service;
+
+use Zend\Mvc\Exception;
+use Zend\Mvc\Router\RouteMatch;
+use Zend\ServiceManager\ConfigInterface;
+use Zend\ServiceManager\ServiceLocatorInterface;
+use Zend\View\Helper as ViewHelper;
+use Zend\View\Helper\HelperInterface as ViewHelperInterface;
+
+/**
+ * @category Zend
+ * @package Zend_Mvc
+ * @subpackage Service
+ */
+class FilterManagerFactory extends AbstractPluginManagerFactory
+{
+ const PLUGIN_MANAGER_CLASS = 'Zend\Validator\FilterPluginManager';
+
+ /**
+ * Create and return the filter plugin manager
+ *
+ * @param ServiceLocatorInterface $serviceLocator
+ * @return FilterPluginManager
+ */
+ public function createService(ServiceLocatorInterface $serviceLocator)
+ {
+ $plugins = parent::createService($serviceLocator);
+ return $plugins;
+ }
+}
@@ -74,6 +74,18 @@ public function createService(ServiceLocatorInterface $serviceLocator)
'Zend\ModuleManager\Feature\ViewHelperProviderInterface',
'getViewHelperConfig'
);
+ $serviceListener->addServiceManager(
+ 'ValidatorManager',
+ 'validators',
+ 'Zend\ModuleManager\Feature\ValidatorProviderInterface',
+ 'getValidatorConfig'
+ );
+ $serviceListener->addServiceManager(
+ 'FilterManager',
+ 'filters',
+ 'Zend\ModuleManager\Feature\FilterProviderInterface',
+ 'getFilterConfig'
+ );
$events = $serviceLocator->get('EventManager');
$events->attach($defaultListeners);
@@ -52,10 +52,12 @@ class ServiceListenerFactory implements FactoryInterface
'ConsoleAdapter' => 'Zend\Mvc\Service\ConsoleAdapterFactory',
'ConsoleRouter' => 'Zend\Mvc\Service\RouterFactory',
'DependencyInjector' => 'Zend\Mvc\Service\DiFactory',
+ 'FilterManager' => 'Zend\Mvc\Service\FilterManagerFactory',
'HttpRouter' => 'Zend\Mvc\Service\RouterFactory',
'Request' => 'Zend\Mvc\Service\RequestFactory',
'Response' => 'Zend\Mvc\Service\ResponseFactory',
'Router' => 'Zend\Mvc\Service\RouterFactory',
+ 'ValidatorManager' => 'Zend\Mvc\Service\ValidatorManagerFactory',
'ViewHelperManager' => 'Zend\Mvc\Service\ViewHelperManagerFactory',
'ViewFeedRenderer' => 'Zend\Mvc\Service\ViewFeedRendererFactory',
'ViewFeedStrategy' => 'Zend\Mvc\Service\ViewFeedStrategyFactory',
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
+
+namespace Zend\Mvc\Service;
+
+use Zend\Mvc\Exception;
+use Zend\Mvc\Router\RouteMatch;
+use Zend\ServiceManager\ConfigInterface;
+use Zend\ServiceManager\ServiceLocatorInterface;
+use Zend\View\Helper as ViewHelper;
+use Zend\View\Helper\HelperInterface as ViewHelperInterface;
+
+/**
+ * @category Zend
+ * @package Zend_Mvc
+ * @subpackage Service
+ */
+class ValidatorManagerFactory extends AbstractPluginManagerFactory
+{
+ const PLUGIN_MANAGER_CLASS = 'Zend\Validator\ValidatorPluginManager';
+
+ /**
+ * Create and return the validator plugin manager
+ *
+ * @param ServiceLocatorInterface $serviceLocator
+ * @return ValidatorPluginManager
+ */
+ public function createService(ServiceLocatorInterface $serviceLocator)
+ {
+ $plugins = parent::createService($serviceLocator);
+ return $plugins;
+ }
+}

0 comments on commit bb80dd3

Please sign in to comment.