You are here

public function ModalPageService::verifyModalShouldAppearOnThisLanguage in Modal 4.1.x

Same name and namespace in other branches
  1. 4.0.x src/Service/ModalPageService.php \Drupal\modal_page\Service\ModalPageService::verifyModalShouldAppearOnThisLanguage()

Method to verify if this Modal Should Appear On This Language.

1 call to ModalPageService::verifyModalShouldAppearOnThisLanguage()
ModalPageService::loadModalsToShow in src/Service/ModalPageService.php
Get modal to show.

File

src/Service/ModalPageService.php, line 316

Class

ModalPageService
Modal Page Service Class.

Namespace

Drupal\modal_page\Service

Code

public function verifyModalShouldAppearOnThisLanguage($modal) {

  // Verify Site Language and Modal Language.
  $languagesToShow = $modal
    ->getLanguagesToShow();

  // Clear 0 values.
  $languagesToShow = array_filter($languagesToShow);

  // If none are selected on this Modal, show it.
  if (empty($languagesToShow)) {
    return TRUE;
  }
  $langCode = $this->languageManager
    ->getCurrentLanguage()
    ->getId();

  // If this language is present on array "Languages to Show" show it.
  if (!empty($languagesToShow[$langCode])) {
    return TRUE;
  }
  return FALSE;
}