Ejemplo n.º 1
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)
 {
     $device = $this->_cacheProvider->load('DEV_' . $deviceID);
     if (empty($device)) {
         $modelDevices = $this->_deviceRepository->getDeviceHierarchy($deviceID);
         $device = new WURFL_CustomDevice($modelDevices, $request);
         $this->_cacheProvider->save('DEV_' . $deviceID, $device);
     }
     return $device;
 }
Ejemplo n.º 2
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)) {
         $deviceId = $this->_userAgentHandlerChain->match($request);
         // save it in cache
         $this->_cacheProvider->save($request->id, $deviceId);
     }
     return $deviceId;
 }
Ejemplo n.º 3
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 string $matchInfo
  * @return WURFL_CustomDevice
  */
 private function getWrappedDevice($deviceID, $matchInfo = null)
 {
     $device = $this->_cacheProvider->load('DEV_' . $deviceID);
     if (empty($device)) {
         $modelDevices = $this->_deviceRepository->getDeviceHierarchy($deviceID);
         $device = new WURFL_CustomDevice($modelDevices, $matchInfo);
         $this->_cacheProvider->save('DEV_' . $deviceID, $device);
     }
     return $device;
     //return new WURFL_Device ( $modelDevice, new WURFL_CapabilitiesHolder ( $modelDevice, $this->_deviceRepository, $this->_cacheProvider ) );
 }
Ejemplo n.º 4
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);
 }