-
Notifications
You must be signed in to change notification settings - Fork 87
Element constructor have different behaviours #63
Comments
I think it's a massive BC break, to be honest.
I think I found the root issue, however: it was due to the fact that 2.7.0 changed the order in which the default initializers were registered, pushing them to the top of the |
Why should you change the map? In v3, if you keep the v2 I read your #65 and the main issue is still there. I'll try to simplify the topic. If
The result is a mess because you have an |
Hi, #43 with #45 introduced an unexpected behaviour that I consider a BC break.
All starts by defining a custom element as
invokable
:At this point, behavious are different depending on built-in or custom elements, and what I specify as
options
array key:Because it's handled by https://github.com/zendframework/zend-servicemanager/blob/release-2.7.6/src/AbstractPluginManager.php#L254
Because it's handled by https://github.com/zendframework/zend-form/blob/release-2.8.1/src/ElementFactory.php#L69
And this is going even harder to understand if we use the
Zend\Form\Factory
Because of https://github.com/zendframework/zend-form/blob/release-2.8.1/src/Factory.php#L204-L214
Without name
The transition fro SMv2 to SMv3 is irrelevant, because
Zend\ServiceManager\Factory\InvokableFactory
acts exactly likeZend\ServiceManager\AbstractPluginManager::createFromInvokable
.The sources of misunderstanding are:
name
acts differently in different contexts, inside or outsideoptions
, through Factory or notElementFactory
to face [1], while custom invokables are instantiated naturallyZend\Form\Element
and not overwrittenThe fact is, if name and options are required, the constructor must be declared in the interface.
If name and options are optional,
Zend\Form\Element
must not have a constructor at all.In my humble opinion, we should decide to be clear about this topic, and:
Zend\Form\Element
Zend\Form\Fieldset::$iterator
[PriorityList]Zend\Form\ElementFactory
(in favour ofcreateFromInvokable
orInvokableFactory
depending on SM version)So
Zend\Form\Element
without constructor will behave like build-in elementsZend\Form\Element
with constructor will receiveoptions
arrayZend\Form\ElementInterface
with constructor will receiveoptions
arrayWith no more array-name.
What do you think?
The text was updated successfully, but these errors were encountered: