- First commit to issue fork.
- Merge request !12451Issue #2699835: Add a method to ContentEntityBase for getting its Bundle entity β (Closed) created by acbramley
- π¦πΊAustralia acbramley
So turns out
EntityTest
has the bundle key, but doesn't technically have bundles. The current code errors out when an entity type doesn't have a bundle key (e.g User). Ideally we remove the key from EntityTest but that may have cascading effects that would balloon this issue. I'm also not keen to add EntityTestWithoutBundle because that is what EntityTest is supposed to be... π€ - π¬π§United Kingdom joachim
EntityTest is magic, it uses EntityTestHelper to define bundles on the fly. I'll open an issue to document that on the entity class.
- π¬π§United Kingdom joachim
I checked, and accessing ->entity on a field that's a string rather than an entity ref works ok, but it feels ugly to be relying on that and accessing a property we know might not exist. So it's better with the guard as it is now.
This is good to go now.
Thanks!
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Left a recommendation on the MR for adding an extra guard to ensure the field is of the correct type. Fine to self RTBC after that change.
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
@acbramley pointed out that this is already covered by
\Drupal\Core\Entity\ContentEntityBase::baseFieldDefinitions
-
larowlan β
committed d3a31a6c on 11.x
Issue #2699835 by joachim, acbramley, tim.plunkett, dawehner, Crell,...
-
larowlan β
committed d3a31a6c on 11.x