Closely related to issue#3042467 on the JSON:API module.
If your application contains an entity which does not implement ContentEntityTypeInterface or ConfigEntityTypeInterface, the module throws a whitescreen/500 error trying to overwrite a resource, which upon checking the logs says:
LogicException: Only content and config entity types are supported. in Drupal\jsonapi_extras\Form\JsonapiResourceConfigForm->getAllFieldNames() (line 542 of /var/www/html//modules/contrib/jsonapi_extras/src/Form/JsonapiResourceConfigForm.php).
It might not be the usual use case to support non-content/config entities, but it would be nice to handle them without throwing a WSOD. This comment contains our use case: https://www.drupal.org/project/jsonapi/issues/3042467#comment-13037962
Comment | File | Size | Author |
---|---|---|---|
#4 | jsonapi_extras-support-all-fieldable-entity-types-3044492-4.patch | 2.27 KB | mxr576 |
|
Comments
Comment #2
Arlina CreditAttribution: Arlina at Chapter Three for Apigee commentedThe following patch replaces the LogicException with a warning message. No fields will be shown on the form for non content/config entities. This way we can safely disable the resource.
Comment #3
mxr576I haven't verified it, but my gut says it should be possible to expose fields from entities that only implements FieldableEntityInterface like the Apigee Edge entities. I would check it before I would commit this fallback behavior.
Comment #4
mxr576This patch applies the same logic fix as #22 implements for the JSONAPI module. Compared with Arlina's patch that just removes the exception, this fix actually exposes fields from a fieldable entity that is not a content entity.
Comment #5
mxr576Comment #6
mxr576Comment #7
e0ipsoThanks all! This is merged now.