3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\InputFilter
;
12 use Zend\InputFilter\Exception
;
13 use Zend\ServiceManager\AbstractPluginManager
;
14 use Zend\ServiceManager\ConfigInterface
;
15 use Zend\ServiceManager\ServiceLocatorInterface
;
16 use Zend\Stdlib\InitializableInterface
;
19 * Plugin manager implementation for input filters.
21 class InputFilterPluginManager
extends AbstractPluginManager
24 * Default set of plugins
28 protected $invokableClasses = array(
29 'inputfilter' => 'Zend\InputFilter\InputFilter',
30 'collection' => 'Zend\InputFilter\CollectionInputFilter',
34 * Whether or not to share by default
38 protected $shareByDefault = false;
41 * @param ConfigInterface $configuration
43 public function __construct(ConfigInterface
$configuration = null)
45 parent
::__construct($configuration);
47 $this->addInitializer(array($this, 'populateFactory'));
51 * Inject this and populate the factory with filter chain and validator chain
55 public function populateFactory($inputfilter)
57 if ($inputfilter instanceof InputFilter
) {
58 $factory = $inputfilter->getFactory();
60 $factory->setInputFilterManager($this);
62 if ($this->serviceLocator
instanceof ServiceLocatorInterface
) {
63 $factory->getDefaultFilterChain()->setPluginManager($this->serviceLocator
->get('FilterManager'));
64 $factory->getDefaultValidatorChain()->setPluginManager($this->serviceLocator
->get('ValidatorManager'));
72 public function validatePlugin($plugin)
74 if ($plugin instanceof InputFilterInterface
) {
75 // Hook to perform various initialization, when the inputfilter is not created through the factory
76 if ($plugin instanceof InitializableInterface
) {
84 throw new Exception\
RuntimeException(sprintf(
85 'Plugin of type %s is invalid; must implement Zend\InputFilter\InputFilterInterface',
86 (is_object($plugin) ?
get_class($plugin) : gettype($plugin))