From fb13f9dc4616593272a739a56077daa353b9dcaf Mon Sep 17 00:00:00 2001 From: Carlos Mella <carlos.mella@mrmilu.com> Date: Thu, 19 Oct 2023 14:03:21 +0200 Subject: [PATCH] If a menu item field has a related entity, add the entity type and UUID to the response. --- src/Plugin/MenuItemsFormat/NestedMenuItemsFormat.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Plugin/MenuItemsFormat/NestedMenuItemsFormat.php b/src/Plugin/MenuItemsFormat/NestedMenuItemsFormat.php index e304f31..a99ff5c 100644 --- a/src/Plugin/MenuItemsFormat/NestedMenuItemsFormat.php +++ b/src/Plugin/MenuItemsFormat/NestedMenuItemsFormat.php @@ -252,6 +252,11 @@ class NestedMenuItemsFormat extends MenuItemsFormatBase implements ContainerFact $field = $menuLinkContentEntity->get($key); $normalization = $this->serializer->normalize($field, 'api_json', ['resource_object' => $resourceObject]); $data[$key] = $normalization->getNormalization(); + /** @var \Drupal\Core\Entity\EntityInterface $entity */ + if ($entity = $field->entity) { + $data[$key]['type'] = $entity->getEntityTypeId() . '--' . $entity->bundle(); + $data[$key]['id'] = $entity->uuid(); + } } } } -- GitLab