You are here

public function LingotekConfigurationService::isEnabled in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  2. 4.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  3. 3.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  4. 3.1.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  5. 3.2.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  6. 3.3.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  7. 3.4.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  8. 3.5.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  9. 3.6.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  10. 3.7.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()
  11. 3.8.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::isEnabled()

Determines whether the given entity type is Lingotek translatable.

@returns bool TRUE if the specified bundle is configured for Lingotek translation. 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 LingotekConfigurationServiceInterface::isEnabled

1 call to LingotekConfigurationService::isEnabled()
LingotekConfigurationService::getEnabledEntityTypes in src/LingotekConfigurationService.php
Gets the entity types that are enabled for Lingotek content translation.

File

src/LingotekConfigurationService.php, line 38
Contains \Drupal\lingotek\LingotekConfigurationService.

Class

LingotekConfigurationService
Service for managing lingotek configuration.

Namespace

Drupal\lingotek

Code

public function isEnabled($entity_type_id, $bundle = NULL) {
  $result = FALSE;
  $config = \Drupal::config('lingotek.settings');
  if ($bundle === NULL) {

    // Check if any bundle is enabled.
    $bundles = \Drupal::entityManager()
      ->getBundleInfo($entity_type_id);
    foreach ($bundles as $bundle_id => $bundle_definition) {
      $result = $this
        ->isEnabled($entity_type_id, $bundle_id);
      if ($result) {
        break;
      }
    }
  }
  else {
    $key = 'translate.entity.' . $entity_type_id . '.' . $bundle . '.enabled';
    $result = !!$config
      ->get($key);
  }
  return $result;
}