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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Arlina created an issue. See original summary.

Arlina’s picture

Status: Active » Needs review
FileSize
567 bytes

The 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.

mxr576’s picture

I 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.

mxr576’s picture

This 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.

mxr576’s picture

mxr576’s picture

e0ipso’s picture

Status: Needs review » Fixed

Thanks all! This is merged now.

  • e0ipso committed 7f9a216 on 8.x-3.x authored by mxr576
    Issue #3044492 by mxr576, Arlina: Support entities that are neither...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.