You are here

public static function LingotekProfile::update in Lingotek Translation 7.7

1 call to LingotekProfile::update()
lingotek_save_config_profile in ./lingotek.admin.inc

File

lib/Drupal/lingotek/LingotekProfile.php, line 65
Defines LingotekProfile

Class

LingotekProfile
A class wrapper for Lingotek Profiles

Code

public static function update($profile_id, array $profile_attributes) {
  if (!isset(self::$profiles[$profile_id])) {
    throw new LingotekException('Unable to update profile "' . $profile_id . '": profile does not exist.');
  }
  $profile = self::loadById($profile_id);
  foreach ($profile_attributes as $key => $value) {
    if (!empty(self::$global_profile[$key]) && self::$global_profile[$key] === $value) {

      // remove any attributes that are the same as the global ones
      $profile
        ->deleteAttribute($key);
    }
    else {

      // keep any custom attributes
      $profile
        ->setAttribute($key, $value);
    }
  }
}