From #2448503: Convert the "Field edit" form to an actual entity form :

(yched) - field_ui's job of "decorate the 4 core entity types (field, field_storage, view_mode, form_mode)" seems a bit randomly split between field_ui_entity_type_build() and field_ui_entity_type_alter() 200 lines lower.
The usual rule of thumb is "hook_*_build() is to add stuff that's not there, hook_*_alter() is to modify what's already there", right ? So it should all go in field_ui_entity_type_build() ?
(amateescu) - Very good point! Although, the hook_*_build() in this case is meant for "adding something new on the top level" afaik, (e.g. a new entity type definition that's not in code, for example what ECK will use), so what we're currently doing in field_ui_entity_type_build() should move to field_ui_entity_type_alter() because we're just altering the definition of already existing entity types

Comments

yched’s picture

Title: centralize logic in field_ui_entity_type_alter » Move the content of field_ui_entity_type_build() into field_ui_entity_type_alter

better title

yched’s picture

Title: Move the content of field_ui_entity_type_build() into field_ui_entity_type_alter » [PP-2] Move the content of field_ui_entity_type_build() into field_ui_entity_type_alter
Status: Active » Postponed
Related issues: +#2448503: Convert the "Field edit" form to an actual entity form, +#2446869: Convert the "Field storage edit" form to an actual entity form
jibran’s picture

Title: [PP-2] Move the content of field_ui_entity_type_build() into field_ui_entity_type_alter » Move the content of field_ui_entity_type_build() into field_ui_entity_type_alter
Status: Postponed » Active

How about that!

amateescu’s picture

Status: Active » Needs review
StatusFileSize
new2.45 KB

Let's do it.

Status: Needs review » Needs work

The last submitted patch, 4: 2459949.patch, failed testing.

amateescu’s picture

Status: Needs work » Needs review
StatusFileSize
new2.64 KB

Let's do it again after pulling latest HEAD :/

tstoeckler’s picture

I think it should be the other way around. Specifically, I disagree with

Although, the hook_*_build() in this case is meant for "adding something new on the top level" afaik, (e.g. a new entity type definition that's not in code, for example what ECK will use)

Everything that can go into build, should. That would be my version of a rule of thumb. With the current patch you cannot e.g. alter the list builder class for field storages (which is totally valid for a better_field_ui.module) without going through the crazy module-weight-dance which the build-then-alter construct circumvents in the first place.

On the other hand, we don't really lose any flexibility by putting all that information into the build phase. Semantically, I think it is also more correct (because we are not altering existing information) but I realize that is arguable.

jibran’s picture

We need beta evaluation here.

amateescu’s picture

StatusFileSize
new4.34 KB

TBH, I don't really care about what goes where for these two hooks :)

https://www.drupal.org/node/2196275 seems to agree with you, so let's do that.

tstoeckler’s picture

Looks good to me, thanks!

Not RTBCing, to see whether I'm the only one of that opinion but codewise this is good to go.

jibran’s picture

Title: Move the content of field_ui_entity_type_build() into field_ui_entity_type_alter » Remove field_ui_entity_type_alter() and move the content to field_ui_entity_type_build()
yched’s picture

Status: Needs review » Reviewed & tested by the community

Yes, agreed with #7, I think we can't be wrong with _build() :-)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Zero disruption and this allows contrib to alter sanely. Committed 76524ee and pushed to 8.0.x. Thanks!

  • alexpott committed 76524ee on 8.0.x
    Issue #2459949 by amateescu: Remove field_ui_entity_type_alter() and...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.