/**
  * the singleton pattern
  *
  * @return Phone_Backend_Asterisk
  */
 public static function getInstance($_url, $_username, $_password)
 {
     if (self::$_instance === NULL) {
         self::$_instance = new Phone_Backend_Asterisk($_url, $_username, $_password);
     }
     return self::$_instance;
 }
Exemplo n.º 2
0
 /**
  * factory function to return a selected phone backend class
  *
  * @param   string $_type
  * @return  Phone_Backend_Interface
  * @throws  Phone_Exception_InvalidArgument
  * @throws  Phone_Exception_NotFound
  */
 public static function factory($_type)
 {
     switch ($_type) {
         case self::ASTERISK:
             if (!isset(self::$_backends[$_type])) {
                 if (isset(Tinebase_Core::getConfig()->asterisk)) {
                     $asteriskConfig = Tinebase_Core::getConfig()->asterisk;
                     $url = $asteriskConfig->managerbaseurl;
                     $username = $asteriskConfig->managerusername;
                     $password = $asteriskConfig->managerpassword;
                 } else {
                     throw new Phone_Exception_NotFound('No settings found for asterisk backend in config file!');
                 }
                 self::$_backends[$_type] = Phone_Backend_Asterisk::getInstance($url, $username, $password);
             }
             $instance = self::$_backends[$_type];
             break;
         case self::CALLHISTORY:
             if (!isset(self::$_backends[$_type])) {
                 self::$_backends[$_type] = new Phone_Backend_Snom_Callhistory();
             }
             $instance = self::$_backends[$_type];
             break;
         case self::SNOM_WEBSERVER:
             if (!isset(self::$_backends[$_type])) {
                 self::$_backends[$_type] = new Phone_Backend_Snom_Webserver();
             }
             $instance = self::$_backends[$_type];
             break;
         default:
             throw new Phone_Exception_InvalidArgument('Unsupported phone backend (' . $_type . ').');
     }
     return $instance;
 }