You are here

private function MenuMultilingualLinkTreeModifier::isTranslatedViewLink in Menu Multilingual 8

Check if link is ViewsMenuLink & translated.

Parameters

mixed $link: The link that will be checked.

string $lang: The language id.

Return value

bool True if link is ViewsMenuLink and has translation.

1 call to MenuMultilingualLinkTreeModifier::isTranslatedViewLink()
MenuMultilingualLinkTreeModifier::linkIsTranslated in src/Menu/MenuMultilingualLinkTreeModifier.php
Check link for translations or current language.

File

src/Menu/MenuMultilingualLinkTreeModifier.php, line 327

Class

MenuMultilingualLinkTreeModifier
Class MenuMultilingualLinkTreeModifier.

Namespace

Drupal\menu_multilingual\Menu

Code

private function isTranslatedViewLink($link, $lang) {
  $result = FALSE;
  if (!$link instanceof ViewsMenuLink) {
    return NULL;
  }
  $view_id = sprintf('views.view.%s', $link
    ->getMetaData()['view_id']);
  $original = $this->configFactory
    ->get($view_id)
    ->get('langcode');

  // Make sure that original configuration exists for given view.
  if (!$original || $lang === $original) {
    $result = TRUE;
  }
  else {

    /** @var \Drupal\language\Config\LanguageConfigOverride $config */
    $config = $this->languageManager
      ->getLanguageConfigOverride($lang, $view_id);

    // Configuration override will be marked as a new if one does not
    // exist for current language (thus has no translation).
    $result = $config
      ->isNew() ? FALSE : TRUE;
  }
  return $result;
}