You are here

public function LingotekConfigurationService::isFieldLingotekEnabled in Lingotek Translation 8

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

Determines if the field is enabled for Lingotek translation.

@returns bool TRUE if the specified field is configured for Lingotek translation.

Parameters

string $entity_type_id: The type of the entity.

string $bundle: The bundle of the entity.

string $field_name: The field of the bundle.

Overrides LingotekConfigurationServiceInterface::isFieldLingotekEnabled

File

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

Class

LingotekConfigurationService
Service for managing lingotek configuration.

Namespace

Drupal\lingotek

Code

public function isFieldLingotekEnabled($entity_type_id, $bundle, $field_name) {
  $field_definitions = \Drupal::entityManager()
    ->getFieldDefinitions($entity_type_id, $bundle);
  $config = \Drupal::config('lingotek.settings');
  $key = 'translate.entity.' . $entity_type_id . '.' . $bundle . '.field.' . $field_name;

  // We allow non-translatable entity_reference_revisions fields through.
  // See https://www.drupal.org/node/2788285
  // We also support paths even if they are not translatable (which may happen
  // if they are computed fields.
  $excluded_types = [
    'path',
    'entity_reference_revisions',
  ];
  return !empty($field_definitions[$field_name]) && ($field_definitions[$field_name]
    ->isTranslatable() || in_array($field_definitions[$field_name]
    ->getType(), $excluded_types)) && !!$config
    ->get($key);
}