You are here

public function LanguageCookieConditionLanguageAccess::evaluate in Language Cookie 8

Evaluates the condition and returns TRUE or FALSE accordingly.

Return value

bool TRUE if the condition has been met, FALSE otherwise.

Overrides LanguageCookieConditionBase::evaluate

File

src/Plugin/LanguageCookieCondition/LanguageCookieConditionLanguageAccess.php, line 76

Class

LanguageCookieConditionLanguageAccess
Class for language access plugin.

Namespace

Drupal\language_cookie\Plugin\LanguageCookieCondition

Code

public function evaluate() {
  $current_language = $this
    ->getCurrentLanguage();
  if ($this->moduleHandler
    ->moduleExists('language_access') && (!$current_language instanceof LanguageInterface || !$this->currentUser
    ->hasPermission('access language ' . $current_language
    ->getId()))) {
    return $this
      ->block();
  }
  return $this
    ->pass();
}