You are here

private function LingotekProfile::__construct in Lingotek Translation 7.7

Constructor.

This is private since we want consumers to instantiate via the factory methods.

Parameters

$profile_name: The name of the profile to load

File

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

Class

LingotekProfile
A class wrapper for Lingotek Profiles

Code

private function __construct($profile_id, $profile_attributes = array()) {
  $this
    ->setId($profile_id);
  $this
    ->setInherit(TRUE);
  $this
    ->refresh();
  if (empty(self::$global_profile)) {
    self::$global_profile = lingotek_get_global_profile();
  }
  if ($profile_id === LingotekSync::PROFILE_DISABLED || $profile_id === LingotekSync::PROFILE_ENABLED) {
    $this
      ->setName($profile_id);
    return $this;
  }
  if ($profile_id === LingotekSync::PROFILE_INHERIT) {
    $this
      ->setName($profile_id);
    return LingotekSync::PROFILE_INHERIT;
  }
  if (empty(self::$profiles[$profile_id]) && !empty($profile_attributes)) {

    // create one on the fly
    $unique_attributes = array();
    foreach ($profile_attributes as $key => $value) {
      if (empty(self::$global_profile[$key]) || self::$global_profile[$key] !== $value) {
        $unique_attributes[$key] = $value;
      }
    }
    self::$profiles[$profile_id] = $unique_attributes;
  }

  // A convenience reference to the current profile.
  $this->profile =& self::$profiles[$profile_id];
}