You are here

public function ContentTranslationManager::isEnabled in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/content_translation/src/ContentTranslationManager.php \Drupal\content_translation\ContentTranslationManager::isEnabled()

Determines whether the given entity type is translatable.

@returns bool TRUE if the specified bundle is translatable. If no bundle is provided returns TRUE if at least one of the entity bundles is translatable.

Parameters

string $entity_type_id: The type of the entity.

string $bundle: (optional) The bundle of the entity. If no bundle is provided, all the available bundles are checked.

Overrides ContentTranslationManagerInterface::isEnabled

File

core/modules/content_translation/src/ContentTranslationManager.php, line 96
Contains \Drupal\content_translation\ContentTranslationManager.

Class

ContentTranslationManager
Provides common functionality for content translation.

Namespace

Drupal\content_translation

Code

public function isEnabled($entity_type_id, $bundle = NULL) {
  $enabled = FALSE;
  if ($this
    ->isSupported($entity_type_id)) {
    $bundles = !empty($bundle) ? array(
      $bundle,
    ) : array_keys($this->entityManager
      ->getBundleInfo($entity_type_id));
    foreach ($bundles as $bundle) {
      $config = $this
        ->loadContentLanguageSettings($entity_type_id, $bundle);
      if ($config
        ->getThirdPartySetting('content_translation', 'enabled', FALSE)) {
        $enabled = TRUE;
        break;
      }
    }
  }
  return $enabled;
}