You are here

public static function SimpleLdapServer::singleton in Simple LDAP 7

Same name and namespace in other branches
  1. 7.2 SimpleLdapServer.class.php \SimpleLdapServer::singleton()

Singleton constructor.

This method should be used whenever a SimpleLdapServer object is needed. By default, a new SimpleLdapServer object is returned, but this can be overridden by setting conf['simple_ldap_server_class'] to an extended class in settings.php.

@throw SimpleLdapException

Parameters

boolean $reset: Forces a new object to be instantiated.

Return value

object SimpleLdapServer object

30 calls to SimpleLdapServer::singleton()
SimpleLdapRole::__construct in simple_ldap_role/SimpleLdapRole.class.php
Constructor.
SimpleLdapRoleCreateDrupalRoleTestCase::testCreateRole in simple_ldap_role/simple_ldap_role.test
Creates a drupal role, and verifies LDAP.
SimpleLdapSSO::__construct in simple_ldap_sso/SimpleLdapSSO.class.php
Constructor.
SimpleLdapUser::__construct in simple_ldap_user/SimpleLdapUser.class.php
Constructor.
SimpleLdapUserDeleteUserTestCase::testDeleteUser in simple_ldap_user/simple_ldap_user.test
Tests user deletion.

... See full list

File

./SimpleLdapServer.class.php, line 59
Class to handle LDAP server connections and related operations.

Class

SimpleLdapServer
Simple LDAP server class.

Code

public static function singleton($reset = FALSE) {
  if ($reset || !isset(self::$instance)) {
    $server_class = variable_get('simple_ldap_server_class', 'SimpleLdapServer');
    self::$instance = new $server_class();
  }

  // Since custom classes are allowed, at least make sure it's a
  // SimpleLdapServer child.
  if (!is_a(self::$instance, 'SimpleLdapServer')) {
    throw new SimpleLdapException('Invalid controller class. Must be of type SimpleLdapServer.');
  }
  return self::$instance;
}