You are here

public function MenuLinkTreeHandler::getMenuLinkItemContent in Menu Item Extras 8

Get Menu Link Content entity content.

Parameters

\Drupal\Core\Menu\MenuLinkInterface $link: Original link entity.

Return value

array Renderable menu item content.

1 call to MenuLinkTreeHandler::getMenuLinkItemContent()
MenuLinkTreeHandler::processMenuLinkTree in src/MenuLinkTreeHandler.php
Process menu tree items. Add menu item content.

File

src/MenuLinkTreeHandler.php, line 74

Class

MenuLinkTreeHandler
Class MenuLinkTreeHandler.

Namespace

Drupal\menu_item_extras

Code

public function getMenuLinkItemContent(MenuLinkInterface $link) {
  $content = [];

  /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_item */
  $menu_item = $this
    ->getMenuLinkItemEntity($link);
  if ($menu_item && $menu_item
    ->hasField('body') && !$menu_item
    ->get('body')
    ->isEmpty()) {
    $field_body = $menu_item
      ->get('body')
      ->getValue();
    $content['body'] = [
      '#type' => 'processed_text',
      '#text' => $field_body[0]['value'],
      '#format' => $field_body[0]['format'],
    ];
  }
  return $content;
}