You are here

class AccountId in Optimizely 8

Same name and namespace in other branches
  1. 8.0 src/AccountId.php \Drupal\optimizely\AccountId

For handling the Optimizely account id number.

Hierarchy

Expanded class hierarchy of AccountId

File

src/AccountId.php, line 8

Namespace

Drupal\optimizely
View source
class AccountId {
  private static $config = NULL;

  /**
   * Retrieve the config object for storing the settings.
   */
  private static function getConfig() {
    if (!self::$config) {
      self::$config = \Drupal::configFactory()
        ->getEditable('optimizely.settings');
    }
    return self::$config;
  }

  /**
   * Retrieve the account id.
   */
  public static function getId() {
    $config = self::getConfig();
    $optimizely_id = $config
      ->get('optimizely_id');
    return $optimizely_id;
  }

  /**
   * Store the account id.
   */
  public static function setId($id) {
    $config = self::getConfig();
    $config
      ->set('optimizely_id', $id);
    $config
      ->save();
    return TRUE;
  }

  /**
   * Delete the account id.
   *
   * Currently, only the account id is stored in the settings,
   * so we just delete everything stored in "optimizely.settings".
   */
  public static function deleteId() {
    $config = self::getConfig();
    $config
      ->delete();
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AccountId::$config private static property
AccountId::deleteId public static function Delete the account id.
AccountId::getConfig private static function Retrieve the config object for storing the settings.
AccountId::getId public static function Retrieve the account id.
AccountId::setId public static function Store the account id.