- Merge request !219feat: #3570382 Avoid fatal when JSON API is activated → (Merged) created by pdureau
Reported by Prasanna-Venkat: https://www.reddit.com/r/drupal/comments/1qp9w78/does_anyone_tried_insta...
JSON:API raise a fatal: "Only content and config entity types are supported"
because our Instance entity is neither a config entity nor a content entity. We did that because:
It is not as easy as extending ContentEntityBase and implementing the related interface:
@@ -53,7 +54,7 @@ use Drupal\ui_patterns\SourcePluginManager;
'plural' => '@count instances',
],
)]
-class Instance extends EntityBase implements InstanceInterface {
+class Instance extends ContentEntityBase implements InstanceInterface {
private const MAX_HISTORY = 10;
@@ -338,7 +339,7 @@ class Instance extends EntityBase implements InstanceInterface {
/**
* {@inheritdoc}
*/
- public function get(string $node_id): array {
+ public function get($node_id): array {
$root = $this->getCurrentState();
$path = $this->getPath($root, $node_id);
$value = NestedArray::getValue($root, $path);
because being a content entity seems to trigger some Drupal mechanisms (like some magic around id property) and at least 8 of our PHPunit tests are failing in:
Apigee module has the same issue by the way: https://github.com/apigee/apigee-edge-drupal/issues/625
Ideally, JSON API must skip the entity it is not able to handle without raising a fatal, but it may be easier/faster to adapt our codebase.
Active
1.0
Main / Misc.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.