You are here

protected function MenuLinkTreeManipulators::getLinkLanguage in Menu Manipulator 8

Same name and namespace in other branches
  1. 8.2 src/Menu/MenuLinkTreeManipulators.php \Drupal\menu_manipulator\Menu\MenuLinkTreeManipulators::getLinkLanguage()
  2. 3.0.x src/Menu/MenuLinkTreeManipulators.php \Drupal\menu_manipulator\Menu\MenuLinkTreeManipulators::getLinkLanguage()
  3. 2.0.x src/Menu/MenuLinkTreeManipulators.php \Drupal\menu_manipulator\Menu\MenuLinkTreeManipulators::getLinkLanguage()

Force the MenuLinkContent to tell us its language code.

Parameters

\Drupal\menu_link_content\Plugin\Menu\MenuLinkContent $link: `The Menu Link Content entity.

Return value

string The Menu Link Content entity's language ID.

1 call to MenuLinkTreeManipulators::getLinkLanguage()
MenuLinkTreeManipulators::filterByCurrentLanguage in src/Menu/MenuLinkTreeManipulators.php
Filter a menu tree by current language MenuLinks.

File

src/Menu/MenuLinkTreeManipulators.php, line 155

Class

MenuLinkTreeManipulators
Provides a couple of menu link tree manipulators.

Namespace

Drupal\menu_manipulator\Menu

Code

protected function getLinkLanguage(MenuLinkContent $link) {
  $matadata = $link
    ->getMetaData();
  $loaded_link = $this->menuLinkContentStorage
    ->load($matadata['entity_id']);
  $loaded_lang_link = $this->entityRepository
    ->getTranslationFromContext($loaded_link);
  return $loaded_lang_link
    ->language()
    ->getId();
}