EntityFormController has code to support entity language and changes made to entity language in form submission.
However, only those features only make sense for content entities (translatability for config entities is entirely different), and the ContentEntityFormController subclass has its own support for content entity translation.
So it seems this language related code in EntityFormController could be simplified ?
| Comment | File | Size | Author |
|---|---|---|---|
| #43 | 2123867-language-EntityFormController-43.patch | 6.42 KB | vijaycs85 |
Comments
Comment #1
yched commentedtags - not sure those are the ones currently used by the initiatives...
Comment #2
plachMore tags
Comment #3
plachHere is a first attempt
Comment #4
plachComment #5
plachAdding new files usally helps
Comment #6
plachTo be fixed on the next reroll.
Comment #7
plachFIxed #6.
Comment #8
yched commentedThanks!
Patch seems sensible to me, but this could sure use other eyes...
Comment #9
amateescu commentedLooks good to me as well, it's just moving some code to the content entity form controller.
Comment #10
gábor hojtsyI agree with the patch. Config entities do not have or use form language like content entities do. I'd like to ensure default config entity language is properly handled for when language element is not on the form though:
Where is the config entity equivalent of this default? There probably (hopefully) is somewhere and hopefully there are tests for that :D #1966436: Default *content* entity languages are not set for entities created with the API may be related.
Comment #11
plachThat hunk is exactly what was bothering me: I hoped to see some test failing, I guess we are missing some coverage.
Comment #12
kfritscheReroll.
To the issue with:
In ConfigEntities we have add always the language on entity_create.
See ConfigStorageController::create()
This is also tested in for example testCustomBlockTypeCreation() in CustomBlockTypeTest.
Thats why removing this doesn't bring up new errors, as we already ensure ConfigEntities have a language set.
And I'm not aware of other base entities, except of Config and Content, which both are getting a language. So in my mind this can go back to RTBC.
Comment #14
kfritscheMessed up the reroll. This should work.
Comment #15
plachSounds good :)
Comment #16
gábor hojtsyAgreed.
Comment #17
xano14: et-form_controller_langcode-2123867-14.patch queued for re-testing.
Comment #18
larowlan14: et-form_controller_langcode-2123867-14.patch queued for re-testing.
Comment #20
larowlanno longer applies, reroll
Comment #22
larowlanComment #24
larowlan20: entity-language-2123867.18.patch queued for re-testing.
Comment #25
plachBack to RTBC
Comment #26
linl commented20: entity-language-2123867.18.patch queued for re-testing.
Comment #27
linl commentedPatch no longer applies, rerolled.
Comment #28
gábor hojtsyLooks like the same as above.
Comment #29
fagohm, +1 on simplifying, but why does that mean we have to separate things into an ContentEntityFormInterface? Having a different base class is one thing, but a different interface everywhere worries me. Then, "content entity interface" is just an agglomeration of interface, if we need a special variant of entity forms for translatable entities, then it should be bound to translatable interface imho.
But then, the concept of entities having a language is part of EntityInterface, consequently I don't see a problem with having getFormLanguage() part of the regular EntityFormInterface. If the problem is only isDefaultFormLangcode() I don't see this as satisfying the need of a separate interface, it can be done by getting the entity + comparing the language anyway, i.e. could be solved in a helper at ContentTranslationController also.
Finally, I don't really see how the patch simplifies things?
Comment #31
gábor hojtsy@fago: the point is to simplify the base entity form interface, because form language code does not apply to that; at least config entities don't use their base forms to edit the entity in other language variants (because the forms are not component base, the route permission models don't support this, etc). So the simplification would be to make the base class simpler in favor of having the relevant logic only at the relevant place.
Looks like you are arguing for a won't fix and have useless code in entity form base class instead that is misleading for config forms?
Comment #32
yched commented(on that same topic : #2151775: EntityFormController does things that only make sense for ContentEntities :-))
Comment #33
gábor hojtsy@fago: what do you think? Would be good to move on with this. It's been on our sprint for long :/
Comment #34
vijaycs85Another re-roll...
Comment #35
yesct commentedI'm trying to reroll this. (https://drupal.org/patch/reroll)
Comment #36
yesct commentedHere was the conflict in Drupal/Core/Entity/EntityFormController:
patch said to do:
if ($entity->entityInfo()->isFieldable()) {
- field_attach_form($entity, $form, $form_state, $this->getFormLangcode($form_state));
+ field_attach_form($entity, $form, $form_state);
So I kept the context line from head, and took out the 4th argument like the patch said to do.
Ended up with:
--
No interdiff since this was a reroll.
New patch attached.
Next steps,
see what testbot says, and
still waiting on a look from @fago I think.
Comment #37
yesct commented36: 2123867-language-EntityFormController-36.patch queued for re-testing.
Comment #38
gábor hojtsy@fago you did not agree with the premise of this patch in December? Do you have any updated thinking? Is this worth even working on? :)
Comment #39
fagoMy thinking is still as said in #29 - so, yeah given that there is not really something left here. One thing I could see us doing is removing function isDefaultFormLangcode(array $form_state) from the interface as this is trivial to implement.
Comment #40
gábor hojtsySo sounds like almost a won't fix then. Does not seem to be anywhere close to as important to need to be on the sprint then.
Comment #43
vijaycs85One of the main concern on #29 is the introduction of new interface just for the language methods makes things harder. However we already got this ContentEntityFormInterface for form display getter/setter. So moving language methods going to be a cleanup now :). Like remove method with just
return TRUE. Adding back to D8MI sprint to track and push or reject and kill :)Comment #44
yched commentedIndeed.
Comment #45
alexpottLet's do this - it is a nice API tidy up and was rtbc'd pre the beta and the impact is minimal.
Committed 7e02386 and pushed to 8.0.x. Thanks!
Comment #47
gábor hojtsyYay!