public function LingotekConfigurationService::setFieldLingotekEnabled in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 4.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.1.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.2.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.3.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.4.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.5.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.6.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.7.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
- 3.8.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setFieldLingotekEnabled()
Sets the field as enabled 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.
bool $enabled: Flag. Defaults to TRUE.
Overrides LingotekConfigurationServiceInterface::setFieldLingotekEnabled
File
- src/
LingotekConfigurationService.php, line 215 - Contains \Drupal\lingotek\LingotekConfigurationService.
Class
- LingotekConfigurationService
- Service for managing lingotek configuration.
Namespace
Drupal\lingotekCode
public function setFieldLingotekEnabled($entity_type_id, $bundle, $field_name, $enabled = TRUE) {
$config = \Drupal::configFactory()
->getEditable('lingotek.settings');
$key = 'translate.entity.' . $entity_type_id . '.' . $bundle . '.field.' . $field_name;
if ($enabled && !$config
->get($key)) {
$config
->set($key, $enabled);
$config
->save();
}
else {
if (!$enabled && $config
->get($key)) {
$config
->clear($key);
$config
->save();
}
}
}