Closed (fixed)
Project:
Drupal core
Version:
8.1.x-dev
Component:
entity system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Dec 2015 at 23:32 UTC
Updated:
4 May 2016 at 08:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
bojanz commentedInitial patch for discussion. Converted nodes as an example.
The original code was written by dawehner, I'm just transporting it.
Note this part:
We don't really have a way of getting a label for the bundle field, so the best we can do is guess and tell children to change it if it's not precise.
Comment #4
dawehnerif there is no bundle entity type but a bundle key, could we provide a string field?
+1 for less boilerplate!
Comment #5
berdirWe do :)
$entity_type->getBundleLabel()
Comment #6
bojanz commentedAddressed #4 and #5.
We obviously want to avoid doing too many conversions. I was thinking of converting a test entity type, but we have dozens of those. Any suggestions?
Comment #8
bojanz commentedAdded missing use statement, converted EntityTest.
Note that the EntityTest bundle field had setRequired(TRUE) on the type definition, do we need to do that in the base class?
Also, the base class is calling ->setRevisionable(TRUE) on the langcode, does that do anything if the parent entity is not revisionable?
Comment #9
tstoecklerYes, definitely. The bundle key field should always be required.
No that's nonsensical and definitely an oversight/leftover/...
Comment #10
bojanz commentedActually, bundle key not being empty is enforced in create() and the field is read-only, so we're safe without "required".
Looks like other base key fields aren't set as required either.
Revisionable entities are definitely calling setRevisionable() on their langcodes, same with translatable entities and setTranslatable().
The question is just whether we should be checking $entity_type->isRevisionable() / $entity_type->isTranslatable() before setting those flags on the field, or if we're safe to just set them anyway.
Comment #12
bojanz commentedComment #14
fagoWhile my initial thought was this should better stay a trait, I guess it makes sense in the base class. It's a reasonable default and if you want to do it different you are free to not call the parent. so +1 on moving it into the base class.
Comment #15
dawehnerThis is probably all we need.
Comment #17
dawehnerThere we go, hopefully.
Comment #19
dawehnerLet's see whether this works out.
Comment #21
dawehnerThere we go.
Comment #22
berdirwhy not do this by default?
It's kind of funny how we now have a test that makes sure we can have a custom named langcode key that's automatically generated ;)
Comment #23
dawehnerIt breaks a couple of tests, but for sure, we could adapt the, as well.
Comment #24
tstoecklerSetting the options in that way does not actually enable the default view and form display determined by the default formatter and widget, so while it might fix tests it does not have any impact on the actual display. So I would like to avoid having those calls in the default implementation because I find them confusing. Not sure how others see that...
Maybe we can also adapt the tests to not require these calls in the first place?
Comment #25
berdirOk, if it doesn't actually do anything, then removing it and updating tests to not look for it seems like the best choice to me as well.
Comment #26
dawehnerI agree
Comment #27
dawehnerThere we go
Comment #28
bojanz commentedGreat! +1 for RTBC.
Comment #29
berdirAgreed, RTBC.
Comment #30
dawehner.
Comment #32
catchLooks great. Committed/pushed to 8.1.x, thanks!
Comment #33
amateescu commentedIs it a regression that node's base fields do not have a description anymore?
Comment #34
bojanz commentedI'd say no, since they never had anything to say (other than repeating the label)
Comment #36
catchComment #37
xjmThis issue is missing a change record. (We should add change records for noteworthy API additions.)
Comment #38
dawehnerI'll write one for all of the 4 entity related ones: https://www.drupal.org/node/2709511
Comment #39
dawehnerAdded stuff to the change record. Feel free to improve it.