Esempio n. 1
0
 public function testShouldDetectAndroid()
 {
     $server = array('HTTP_USER_AGENT' => 'Mozilla/5.0 (Linux; U; Android 2.1-update1; ja-jp; HTCX06HT Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17');
     $request = new Request();
     $request->initialize(array(), array(), array(), array(), array(), $server);
     $mobile = new Detector();
     $result = $mobile->detect($request);
     $this->assertEquals($result, 'iphone', '->detect() returns iphone');
 }
 /**
  * detect
  *
  * @param  Symfony\Component\HttpFoundation\Request $request
  *
  * @return string  The type name of the user agent (ex. 'docomo')
  */
 public function detect(Request $request)
 {
     $ua = parent::detect($request);
     if (!$ua) {
         $mobile = \Net_UserAgent_Mobile::factory($request->server->get('HTTP_USER_AGENT'));
         $ua = strtolower($mobile->getCarrierlongName());
     }
     return $ua;
 }