public function LingotekProfile::setAttribute in Lingotek Translation 7.7
6 calls to LingotekProfile::setAttribute()
- LingotekProfile::disableTargetLocale in lib/
Drupal/ lingotek/ LingotekProfile.php - LingotekProfile::setAutoDownload in lib/
Drupal/ lingotek/ LingotekProfile.php - LingotekProfile::setName in lib/
Drupal/ lingotek/ LingotekProfile.php - LingotekProfile::setNodeBased in lib/
Drupal/ lingotek/ LingotekProfile.php - LingotekProfile::setProjectId in lib/
Drupal/ lingotek/ LingotekProfile.php
File
- lib/
Drupal/ lingotek/ LingotekProfile.php, line 472 - Defines LingotekProfile
Class
- LingotekProfile
- A class wrapper for Lingotek Profiles
Code
public function setAttribute($attrib_name, $value, $target_locale = NULL) {
if ($this
->isProtectedAttribute($attrib_name)) {
return;
}
$original_value = $this
->getAttribute($attrib_name, $value);
if ($target_locale) {
// Set the language-specific attribute if different from the base attribute
if ($value !== $original_value) {
$this
->initTargetLocaleOverride($target_locale);
$this->profile['target_language_overrides'][$target_locale][$attrib_name] = $value;
}
else {
$this
->deleteAttribute($attrib_name, $target_locale);
// Clean up any empty language overrides
if (empty($this->profile['target_language_overrides'][$target_locale])) {
unset($this->profile['target_language_overrides'][$target_locale]);
}
}
}
else {
// Set the base attribute if different from the global attribute
if (isset(self::$global_profile[$attrib_name])) {
$original_value = self::$global_profile[$attrib_name];
}
if ($value !== $original_value) {
$this->profile[$attrib_name] = $value;
}
else {
$this
->deleteAttribute($attrib_name);
}
}
// Clean up target language attribute if empty
if (empty($this->profile['target_language_overrides'])) {
unset($this->profile['target_language_overrides']);
}
}