예제 #1
0
 /**
  * Adds the pair $userAgent, $deviceID to the clusters they belong to.
  *
  * @param String $userAgent
  * @param String $deviceID
  * @see WURFL_Handlers_Handler::filter()
  */
 public function filter($userAgent, $deviceID)
 {
     WURFL_Handlers_Utils::reset();
     $generic_normalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers();
     $userAgent = $generic_normalizer->normalize($userAgent);
     $this->_userAgentHandlers[0]->filter($userAgent, $deviceID);
 }
예제 #2
0
 /**
  * Wraps the model device with WURFL_Xml_ModelDevice.  This function takes the
  * Device ID and returns the WURFL_CustomDevice with all capabilities.
  *
  * @param string $deviceID
  * @param WURFL_Request_GenericRequest|null $request
  * @return WURFL_CustomDevice
  */
 private function getWrappedDevice($deviceID, $request = null)
 {
     $modelDevices = $this->_cacheProvider->load('DEVS_' . $deviceID);
     if (empty($modelDevices)) {
         $modelDevices = $this->_deviceRepository->getDeviceHierarchy($deviceID);
     }
     $this->_cacheProvider->save('DEVS_' . $deviceID, $modelDevices);
     if ($request === null) {
         // If a request was not provided, we generate one from the WURFL entry itself
         // to help resolve the virtual capabilities
         $requestFactory = new WURFL_Request_GenericRequestFactory();
         $request = $requestFactory->createRequestForUserAgent($modelDevices[0]->userAgent);
         $genericNormalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers();
         $request->userAgentNormalized = $genericNormalizer->normalize($request->userAgent);
     }
     // The CustomDevice is not cached since virtual capabilities must be recalculated
     // for every different request.
     return new WURFL_CustomDevice($modelDevices, $request);
 }
예제 #3
0
 public function setUp()
 {
     $this->normalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers();
 }
예제 #4
0
 /**
  * Returns the device id for the device that matches the $request
  * @param WURFL_Request_GenericRequest $request WURFL Request object
  * @return string WURFL device id
  */
 private function deviceIdForRequest($request)
 {
     $deviceId = $this->_cacheProvider->load($request->id);
     if (empty($deviceId)) {
         $generic_normalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers();
         $request->userAgentNormalized = $generic_normalizer->normalize($request->userAgent);
         if (WURFL_Configuration_ConfigHolder::getWURFLConfig()->isHighPerformance() && WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($request->userAgentNormalized)) {
             // This device has been identified as a web browser programatically, so no call to WURFL is necessary
             return WURFL_Constants::GENERIC_WEB_BROWSER;
         }
         $deviceId = $this->_userAgentHandlerChain->match($request);
         // save it in cache
         $this->_cacheProvider->save($request->id, $deviceId);
     } else {
         $request->matchInfo->from_cache = true;
         $request->matchInfo->lookup_time = 0.0;
     }
     return $deviceId;
 }