public function LingotekConfigurationService::shouldFieldLingotekEnabled in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 8.2 src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 4.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 3.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 3.1.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 3.2.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 3.3.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 3.4.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 3.5.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 3.6.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
- 3.7.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::shouldFieldLingotekEnabled()
File
- src/
LingotekConfigurationService.php, line 331
Class
- LingotekConfigurationService
- Service for managing lingotek configuration.
Namespace
Drupal\lingotekCode
public function shouldFieldLingotekEnabled($entity_type_id, $bundle, $field_name) {
$should = FALSE;
$field_definitions = \Drupal::service('entity_field.manager')
->getFieldDefinitions($entity_type_id, $bundle);
$config = \Drupal::config('lingotek.settings');
$key = 'translate.entity.' . $entity_type_id . '.' . $bundle . '.field.' . $field_name;
$saved_value = $config
->get($key);
$default_enabled = [
'string',
'image',
'text',
'text_with_summary',
'text_long',
'string_long',
'path',
'entity_reference_revisions',
'cohesion_entity_reference_revisions',
];
if ($saved_value === NULL) {
$type = $field_definitions[$field_name]
->getType();
$should = !empty($field_definitions[$field_name]) && in_array($type, $default_enabled);
}
return $should;
}