class AccountId in Optimizely 8
Same name and namespace in other branches
- 8.0 src/AccountId.php \Drupal\optimizely\AccountId
For handling the Optimizely account id number.
Hierarchy
- class \Drupal\optimizely\AccountId
Expanded class hierarchy of AccountId
File
- src/AccountId.php, line 8 
Namespace
Drupal\optimizelyView 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
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| AccountId:: | private static | property | ||
| AccountId:: | public static | function | Delete the account id. | |
| AccountId:: | private static | function | Retrieve the config object for storing the settings. | |
| AccountId:: | public static | function | Retrieve the account id. | |
| AccountId:: | public static | function | Store the account id. | 
