[fw-general] Initializer is called twice for each instance
Hi, I added an initializer for the InputFilterPluginManager like this: - return array( 'input_filters' = array( 'initializers'= array( 'CsrfInput' = 'MyLib\InputFilter\CsrfInputInitializer', ), ), ); - The initializer class looks this: - namespace MyLib\InputFilter; use Zend\ServiceManager\InitializerInterface; use Zend\ServiceManager\ServiceLocatorInterface; class CsrfInputInitializer implements InitializerInterface { public function initialize( $instance, ServiceLocatorInterface $serviceLocator ) { \Zend\Debug\Debug::dump(get_class($instance)); } } - When I run this my class User\InputFilter\ProfileFilter is dumped twice. Even all other input filter classes are dumped twice. When I add the following line: \Zend\Debug\Debug::dump(spl_object_hash($instance)); I get different hashes for each call of the initializer. So two objects are created although my input filters are not defined as shared = false. Is this a bug or a feature? Thanks, Ralf -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
Re: [fw-general] Initializer is called twice for each instance
See https://github.com/zendframework/zf2/blob/release-2.2.0/library/Zend/InputFilter/InputFilterPluginManager.php#L33-L38 Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 17 June 2013 11:42, Ralf Eggert r.egg...@travello.de wrote: Hi, I added an initializer for the InputFilterPluginManager like this: - return array( 'input_filters' = array( 'initializers'= array( 'CsrfInput' = 'MyLib\InputFilter\CsrfInputInitializer', ), ), ); - The initializer class looks this: - namespace MyLib\InputFilter; use Zend\ServiceManager\InitializerInterface; use Zend\ServiceManager\ServiceLocatorInterface; class CsrfInputInitializer implements InitializerInterface { public function initialize( $instance, ServiceLocatorInterface $serviceLocator ) { \Zend\Debug\Debug::dump(get_class($instance)); } } - When I run this my class User\InputFilter\ProfileFilter is dumped twice. Even all other input filter classes are dumped twice. When I add the following line: \Zend\Debug\Debug::dump(spl_object_hash($instance)); I get different hashes for each call of the initializer. So two objects are created although my input filters are not defined as shared = false. Is this a bug or a feature? Thanks, Ralf -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
Re: [fw-general] Initializer is called twice for each instance
Yep. Marco Pivetta schrieb am 17.06.2013 21:56: See https://github.com/zendframework/zf2/blob/release-2.2.0/library/Zend/InputFilter/InputFilterPluginManager.php#L33-L38 It took me two hours to figure that out and to understand why this is done. Just forgot to mention it here, sorry. Regards, Ralf -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
Re: [fw-general] Initializer is called twice for each instance
Yep. Marco Pivetta schrieb am 17.06.2013 21:56: See https://github.com/zendframework/zf2/blob/release-2.2.0/library/Zend/InputFilter/InputFilterPluginManager.php#L33-L38 It took me two hours to figure that out and to understand why this is done. Just forgot to mention it here, sorry. Regards, Ralf -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com