You are here

public function LanguageSelectionPageConditionIgnoreNeutral::evaluate in Language Selection Page 8.2

Evaluates the condition and returns TRUE or FALSE accordingly.

Return value

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

Overrides LanguageSelectionPageConditionBase::evaluate

File

src/Plugin/LanguageSelectionPageCondition/LanguageSelectionPageConditionIgnoreNeutral.php, line 80

Class

LanguageSelectionPageConditionIgnoreNeutral
Class for the Ignore Language Neutral plugin.

Namespace

Drupal\language_selection_page\Plugin\LanguageSelectionPageCondition

Code

public function evaluate() {

  // Check if the "ignore language neutral" option is checked.
  // If so, we will check if the entity is translatable, so that pages for
  // entities with default entity language set to LANGCODE_NOT_APPLICABLE or
  // LANGCODE_NOT_SPECIFIED, or where the content type is not translatable,
  // are ignored.
  if ($this->configuration[$this
    ->getPluginId()]) {
    foreach ($this->routeMatch
      ->getParameters() as $parameter) {
      if ($parameter instanceof ContentEntityInterface) {
        if (!$parameter
          ->isTranslatable()) {
          return $this
            ->block();
        }
      }
    }
  }
  return $this
    ->pass();
}