Playing with drupal 8 entities, I noticed theses errors with the entity class generated :
1- When you use an entity content generated and trying to reference this entity (with an entity_reference field) from an another entity (let's say Article content type).
When you try to add a new article, you've got this fatal error.
Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template "canonical" found for the "note" entity type in Drupal\Core\Entity\Entity->urlInfo() (line 188 of /srv/www/drupal8/core/lib/Drupal/Core/Entity/Entity.php).
It's because the canonical link is missing in the annotations of the entity
2- If you reference an another entity from the entity content generated (always with an entity_reference field), you've got this fatal error when trying to add the entity_reference field.
InvalidArgumentException: Field user_id is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 339 of /srv/www/drupal8/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
It's because all the functions about the owner in the Entity Class assume there is a field user_id which handle the author feature. But this field is not created in the baseFieldDefinitions.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | console-entity-canonical-link-user_id-2363693-1.patch | 1.83 KB | flocondetoile |
Comments
Comment #1
flocondetoileThanks for your review
Comment #2
flocondetoileComment #3
kgaut commentedHello,
I was facing this issue when creating a entity with a entity_reference to another custom entity, on the entity add form.
I've just edited my two entities by adding the code proposed. And it's working !
Thanks flocondetoile !
Comment #4
kgaut commentedAnd I've just patched my console module, tried to generate new entities, everythings works as designed.
Comment #5
jmolivas commentedPatch tested and applied, this change will be included in next release
Comment #6
jmolivas commentedThanks for the patch @flocondetoile
Comment #7
jmolivas commentedFixed on new release
https://github.com/hechoendrupal/DrupalAppConsole/releases/tag/0.2.17
Try updating project
Comment #8
jmolivas commented