You are here

public function MenuLinkContentMultilingual::getLanguage in Menu Multilingual 8

Gets the language of the menu link.

Return value

string The language id.

Throws

\Drupal\Component\Plugin\Exception\PluginException

File

src/Plugin/Menu/MenuLinkContentMultilingual.php, line 22

Class

MenuLinkContentMultilingual
Provides the menu link plugin for content menu links.

Namespace

Drupal\menu_multilingual\Plugin\Menu

Code

public function getLanguage() {

  // We only need to get the title from the actual entity if it may be a
  // translation based on the current language context. This can only happen
  // if the site is configured to be multilingual.
  if ($this->languageManager
    ->isMultilingual()) {
    return $this
      ->getEntity()
      ->get('langcode')->value;
  }
  return $this->languageManager
    ->getDefaultLanguage()
    ->getId();
}