How to load a node given a menu link id?

by Alex   Last Updated November 13, 2017 22:07 PM

I have this id via $link->getParent():


How do I get the node id of that menu link?

Tags : 8 entities

Answers 2

You can load the node from the (already depreciated) entityManager using the UUID:

$node = \Drupal::entityManager()->loadEntityByUuid('6cf83fce-228f-42da-bc39-bea06c767510');
May 20, 2016 20:25 PM

See EntityRepository::loadEntityByUuid() for a non-deprecated way of loading by UUID.

November 13, 2017 22:04 PM

Related Questions

How to create a custom template for entities?

Updated April 07, 2015 03:03 AM

Drupal 8 Custom Entities from a UI?

Updated July 14, 2015 15:03 PM