- Issue created by @kopeboy
- 🇺🇸United States jeffam
At the moment, you can only add config entities programmatically. This is a limitation of dynamic entity reference, and it looks like there hasn't been much movement on a solution: https://www.drupal.org/project/dynamic_entity_reference/issues/2997727 →
Here's an example snippet that adds a taxonomy vocabulary config entity to a collection:
$vocab = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->create([ 'langcode' => 'en', 'status' => TRUE, 'name' => 'My taxonomy vocabulary', 'vid' => 'my_taxonomy', ]); $vocab->save(); if ($vocab) { // Add the vocab to this new collection. $collection_item_vocab = $this->entityTypeManager->getStorage('collection_item')->create([ 'type' => 'default', 'collection' => 1, 'canonical' => TRUE, 'weight' => 10, ]); $collection_item_vocab->item = $vocab; $collection_item_vocab->save(); }
- Status changed to Closed: works as designed
9 days ago 4:09pm 28 March 2025