private function MenuMultilingualLinkTreeModifier::entityHasTranslation in Menu Multilingual 8
Helper method to check if entity is translateable.
Parameters
\Drupal\menu_multilingual\Plugin\Menu\MenuLinkContentMultilingual|\Drupal\Core\Entity\ContentEntityBase $entity: The base entity object or menu link plugin to get translations on.
string $lang: The language id.
Return value
bool Return true when language matches translations languages, or non translatable.
2 calls to MenuMultilingualLinkTreeModifier::entityHasTranslation()
- MenuMultilingualLinkTreeModifier::isTranslatedMenuLinkContentMultilingual in src/
Menu/ MenuMultilingualLinkTreeModifier.php - Check if link is MenuLinkContent & translated.
- MenuMultilingualLinkTreeModifier::linkedEntityHasTranslationsOrIsDefault in src/
Menu/ MenuMultilingualLinkTreeModifier.php - Check menu item link for translations or current language.
File
- src/
Menu/ MenuMultilingualLinkTreeModifier.php, line 301
Class
- MenuMultilingualLinkTreeModifier
- Class MenuMultilingualLinkTreeModifier.
Namespace
Drupal\menu_multilingual\MenuCode
private function entityHasTranslation($entity, $lang) {
// Return false for "Not Specified" language (langcode 'und').
if ($entity
->language()
->getId() == 'und') {
return FALSE;
}
elseif (!method_exists($entity, 'isTranslatable') || $entity
->language()
->getId() === 'zxx') {
return TRUE;
}
$translation_codes = array_keys($entity
->getTranslationLanguages());
return in_array($lang, $translation_codes);
}