Ejemplo n.º 1
0
 /**
  * Attempts to return a reference to a concrete
  * Horde_Kolab_Resource_Getfreebusy instance based on $driver.
  *
  * It will only create a new instance if no Horde_Kolab_Resource_Getfreebusy
  * instance with the same parameters currently exists.
  *
  * This method must be invoked as:
  * <code>$var = Horde_Kolab_Resource_Getfreebusy::singleton();</code>
  *
  * @param mixed $driver The type of concrete
  *                      Horde_Kolab_Resource_Getfreebusy subclass to
  *                      return.
  * @param array $params A hash containing any additional configuration or
  *                      connection parameters a subclass might need.
  *
  * @return Horde_Token The concrete Horde_Kolab_Resource_Getfreebusy
  *                      reference, or false on error.
  */
 public static function singleton($driver = null, $params = array())
 {
     global $conf;
     if (isset($GLOBALS['KOLAB_FILTER_TESTING'])) {
         $driver = 'mock';
         $params['data'] = $GLOBALS['KOLAB_FILTER_TESTING'];
     }
     if (empty($driver)) {
         if (isset($conf['freebusy']['driver'])) {
             $driver = $conf['freebusy']['driver'];
         } else {
             $driver = 'Kolab';
         }
     }
     ksort($params);
     $sig = hash('md5', serialize(array($driver, $params)));
     if (!isset(self::$_instances[$sig])) {
         self::$_instances[$sig] = Horde_Kolab_Resource_Freebusy::factory($driver, $params);
     }
     return self::$_instances[$sig];
 }