Example #1
0
 /**
  * Constructor.
  *
  * @param string $userAgent  HTTP user agent string
  * @param string $httpAccept HTTP accept header
  */
 public function __construct($userAgent = null, $httpAccept = null)
 {
     // Don't call parent::__construct as it attempts to connect the DB
     // every time (we want it rather static) - following is other stuff
     // from there:
     $this->errors = array();
     $this->capabilities = array();
     $this->matcherHistory = array();
     $this->rootdir = dirname(__FILE__) . '/';
     // Create the database connection only once
     // @see Tx_ContextsWurfl_Api_Wurfl_DatabaseConnector::connect()
     if (!self::$staticDb) {
         $db = new Tx_ContextsWurfl_Api_Wurfl_DatabaseConnector();
         if (!$db->connect()) {
             throw new TeraWurflDatabaseException('Cannot connect to database: ' . $db->getLastError());
         }
         self::$staticDb = $db;
     }
     $this->db = self::$staticDb;
     try {
         // Get device capabilities
         $this->getDeviceCapabilitiesFromAgent($userAgent, $httpAccept);
     } catch (Exception $e) {
         //no nothing here.
         // we show errors in the context wurfl configuration
     }
 }