You are here

public function MenuLinkTreeHandler::getMenuLinkContentViewMode in Menu Item Extras 8.2

Get menu_link_content view mode.

Parameters

\Drupal\menu_link_content\MenuLinkContentInterface $entity: Link object.

Return value

string View mode machine name.

Overrides MenuLinkTreeHandlerInterface::getMenuLinkContentViewMode

3 calls to MenuLinkTreeHandler::getMenuLinkContentViewMode()
MenuLinkTreeHandler::getMenuLinkItemContent in src/Service/MenuLinkTreeHandler.php
Get Menu Link Content entity content.
MenuLinkTreeHandler::getMenuLinkItemViewMode in src/Service/MenuLinkTreeHandler.php
Get Menu Link Item view mdoe.
MenuLinkTreeHandler::isMenuLinkDisplayedChildren in src/Service/MenuLinkTreeHandler.php
Checks if Menu Link Children is enabled to display.

File

src/Service/MenuLinkTreeHandler.php, line 69

Class

MenuLinkTreeHandler
Class MenuLinkTreeHandler.

Namespace

Drupal\menu_item_extras\Service

Code

public function getMenuLinkContentViewMode(MenuLinkContentInterface $entity) {
  $view_mode = 'default';
  if (!$entity
    ->get('view_mode')
    ->isEmpty()) {
    $value = $entity
      ->get('view_mode')
      ->first()
      ->getValue();
    if (!empty($value['value'])) {
      $view_mode = $value['value'];
    }
  }
  return $view_mode;
}