Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
diff --git a/src/MetaEntityRepositoryInterface.php b/src/MetaEntityRepositoryInterface.php
index f3ec3d9..ca8a531 100644
--- a/src/MetaEntityRepositoryInterface.php
+++ b/src/MetaEntityRepositoryInterface.php
@@ -63,4 +63,15 @@ interface MetaEntityRepositoryInterface {
+ /**
+ * Returns a list of meta entity types that are configured with auto-creation.
+ *
+ * @return string[]
+ * A list o meta entity type IDs.
+ */
Small typo "A list _of_ meta entity type IDs".
--- a/src/MetaEntityRepository.php
+++ b/src/MetaEntityRepository.php
@@ -175,4 +175,41 @@ class MetaEntityRepository implements MetaEntityRepositoryInterface {
+ public function getTypesWithAutoCreation(ContentEntityInterface $entity): array {
+ $cid = 'auto_create';
+ $bundle = $entity->bundle() ?: $entity->getEntityTypeId();
What motivated you to distrust the value returned by $entity->bundle() and provide a fallback to the entity type ID? Did you see a case where a certain entity type returns NULL for the bundle?
The method as described in EntityInterface::bundle() already specifies that the entity type ID is returned as a fallback, and returning NULL is not allowed according to the interface:
/**
* Gets the bundle of the entity.
*
* @return string
* The bundle of the entity. Defaults to the entity type ID if the entity
* type does not make use of different bundles.
*/
public function bundle();
Of course in Drupal core this is not enforced yet (it lacks strict return types), but it seems to me if you found a case where this returns NULL then this is probably a bug in the entity type, and not strictly needed for us to provide a fallback.
Comments
Comment #2
claudiu.cristeaPatch
Comment #4
claudiu.cristeaFixing tests.
Comment #5
claudiu.cristeaMore tests fixes.
Comment #6
pfrenssenSmall typo "A list _of_ meta entity type IDs".
What motivated you to distrust the value returned by
$entity->bundle()and provide a fallback to the entity type ID? Did you see a case where a certain entity type returnsNULLfor the bundle?The method as described in
EntityInterface::bundle()already specifies that the entity type ID is returned as a fallback, and returningNULLis not allowed according to the interface:Of course in Drupal core this is not enforced yet (it lacks strict return types), but it seems to me if you found a case where this returns
NULLthen this is probably a bug in the entity type, and not strictly needed for us to provide a fallback.Small typo: double space after "Settings for ".
Comment #7
ankithashettyUpdated the patch in #5 addressing #6.1 and #6.3. Retaining status as "Needs work" to address #6.2... Thanks!
Comment #8
claudiu.cristea@pfrenssen #6.2, very good observation. Fixed.
@ankithashetty, thank you for fixing.
Comment #10
claudiu.cristeaFixing test failure and coding standards. Adding credits.
Comment #11
claudiu.cristeaReroll.
Comment #12
claudiu.cristeaCS fix.
Comment #13
claudiu.cristeaThe interdiff was correct in #12 but not the patch.
Comment #14
pfrenssenThanks for the fast fixes @ankithashetty and @claudiu.cristea!
It's looking good now, thanks a lot!
Comment #16
pfrenssen