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

[Form] [FormElementManager] don't overwrite form factory if already set #3735

Merged
merged 1 commit into from
Feb 19, 2013

Conversation

radnan
Copy link
Contributor

@radnan radnan commented Feb 8, 2013

Don't overwrite factory in case other initializers are called beforehand that set the form factory, or attach an input filter factory to it.

@ralphschindler
Copy link
Member

Unit test?

@ghost ghost assigned ralphschindler Feb 15, 2013
@@ -84,7 +84,7 @@ public function __construct(ConfigInterface $configuration = null)
public function injectFactory($element)
{
if ($element instanceof FormFactoryAwareInterface) {
$element->setFormFactory(new Factory($this));
$element->getFormFactory()->setFormElementManager($this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are actually synonymous -- getFormFactory() will create a form factory instance internally. The old code is actually more performant than your change as it bypasses the getter and immediately sets a new instance that has the element manager composed. (The reason no unit tests fail currently is because we actually have a test that verifies that the form element manager is identical in the two objects.)

Can you indicate why you would want to alter this? A unit test detailing the use case would make the most sense, as right now, I'm unclear what the purpose of the change is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, your subject line details it: you want to inject the element manager into an existing factory, if present.

@ghost ghost assigned weierophinney Feb 19, 2013
weierophinney added a commit that referenced this pull request Feb 19, 2013
- Test demonstrates that factory composed by object implementing
  FormFactoryAwareInterface is not overwritten, but *is* injected with
  FormElementManager instance.
weierophinney added a commit that referenced this pull request Feb 19, 2013
@weierophinney weierophinney merged commit 6ce846e into zendframework:develop Feb 19, 2013
weierophinney added a commit that referenced this pull request Feb 19, 2013
@weierophinney
Copy link
Member

Added a unit test on merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants