-
Notifications
You must be signed in to change notification settings - Fork 2.5k
FormElementManager: Only initialize a shared element once #6132
FormElementManager: Only initialize a shared element once #6132
Conversation
@Danielss89 I know it is a rare case, but what if the service is unset/replaced? |
An alternate approach to fix this is to move the |
@Ocramius Hm, what about using spl_object_hash in the $initializedPlugins? |
As far as I can see, the I think moving it to an initializer is fine as long as we ensure that it is at the bottom of the initializer stack |
* Keep track of which plugins have been intizalied | ||
* @var array | ||
*/ | ||
protected $initializedPlugins = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed anymore
You are right, i need to sleep. |
@Ocramius Ok, cleaned up. |
@Danielss89 I'd like to see some unit tests. While I'm pretty sure it does what you want it to, we really need to verify it. |
@Danielss89 yes, a test that requires the same (shared) plugin twice should do the trick. |
…t()` on shared form elements multiple times
… FormElementManager
…ent-manager-multiple-shared-element-init Tests for zendframework#6132 form element manager multiple shared element init
@weierophinney Tests added, with thankts to @Ocramius |
…d-elements-once' Close #6132
PHP54 for short array/echo support Zend\Form due to zendframework/zendframework#6132
If you call $formElementManager->get('My\Element'); several times, My\Element->init() is called each time.
This is correct if the element is not shared, but if the element is shared it should only be called once.