You are here

protected function TaxonomyStorages::needsTranslatedContent in Client-side Hierarchical Select 8

Same name and namespace in other branches
  1. 8.3 src/TaxonomyStorages.php \Drupal\cshs\TaxonomyStorages::needsTranslatedContent()
  2. 8.2 src/TaxonomyStorages.php \Drupal\cshs\TaxonomyStorages::needsTranslatedContent()

Returns the state of whether content translation needed.

Return value

bool The state.

1 call to TaxonomyStorages::needsTranslatedContent()
CshsOptionsFromHelper::getOptions in src/CshsOptionsFromHelper.php
Collects the options.

File

src/TaxonomyStorages.php, line 80

Class

TaxonomyStorages
The taxonomy storages.

Namespace

Drupal\cshs

Code

protected function needsTranslatedContent() : bool {
  if (NULL === $this->needsTranslatedContent) {

    /* @var \Drupal\Core\Language\LanguageManagerInterface $language_manager */
    $language_manager = \Drupal::service('language_manager');
    $default_language = $language_manager
      ->getDefaultLanguage();
    $content_language = $language_manager
      ->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
    $this->needsTranslatedContent = $default_language
      ->getId() !== $content_language
      ->getId();
  }
  return $this->needsTranslatedContent;
}