/** * Load a login driver to the array of loaded drivers * * @param array settings for the new driver * @throws Auth_Exception on driver load failure */ public static function factory($custom = array()) { // Driver is given as array key or just string in custom $custom = !is_array($custom) ? array('driver' => $custom) : $custom; $config = \Config::get('auth.' . $custom['driver'] . '_config', array()); $config = array_merge($config, $custom); // Driver must be set if (empty($config['driver']) || !is_string($config['driver'])) { throw new \Auth_Exception('No auth driver given.'); } // determine the driver to load $driver = \Auth_Login_Driver::factory($config); // get the driver's cookie name $id = $driver->get_id(); // do we already have a driver instance for this cookie? if (isset(static::$_instances[$id])) { // if so, they must be using the same driver class! $class = get_class($driver); if (!static::$_instances[$id] instanceof $class) { throw new \Auth_Exception('You can not instantiate two different login drivers using the same id "' . $id . '"'); } } else { // store this instance static::$_instances[$id] = $driver; } return static::$_instances[$id]; }