You are here

protected function MenuLinkTreeHandler::getMenuLinkItemEntity in Menu Item Extras 8

Get menu_link_content entity.

Parameters

\Drupal\Core\Menu\MenuLinkInterface $link: Link object.

Return value

\Drupal\menu_link_content\Entity\MenuLinkContent|null Menu Link Content entity.

1 call to MenuLinkTreeHandler::getMenuLinkItemEntity()
MenuLinkTreeHandler::getMenuLinkItemContent in src/MenuLinkTreeHandler.php
Get Menu Link Content entity content.

File

src/MenuLinkTreeHandler.php, line 50

Class

MenuLinkTreeHandler
Class MenuLinkTreeHandler.

Namespace

Drupal\menu_item_extras

Code

protected function getMenuLinkItemEntity(MenuLinkInterface $link) {
  $menu_item = NULL;
  $metadata = $link
    ->getMetaData();
  if (!empty($metadata['entity_id'])) {

    /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_item */
    $menu_item = $this->entityTypeManager
      ->getStorage('menu_link_content')
      ->load($metadata['entity_id']);
  }
  if ($menu_item) {
    $menu_item = $this->entityRepository
      ->getTranslationFromContext($menu_item);
  }
  return $menu_item;
}