Exemplo n.º 1
0
 /**
  * Patch an existing $device with a $patchingDevice
  * @param WURFL_Xml_ModelDevice $device
  * @param WURFL_Xml_ModelDevice $patchingDevice
  * @return WURFL_Xml_ModelDevice Patched device
  */
 public function patch($device, $patchingDevice)
 {
     if (!$this->haveSameId($device, $patchingDevice)) {
         return $patchingDevice;
     }
     $groupIdCapabilitiesMap = WURFL_WURFLUtils::array_merge_recursive_unique($device->getGroupIdCapabilitiesMap(), $patchingDevice->getGroupIdCapabilitiesMap());
     return new WURFL_Xml_ModelDevice($device->id, $device->userAgent, $device->fallBack, $device->actualDeviceRoot, $device->specific, $groupIdCapabilitiesMap);
 }
	/**
	 * Pathces a single device with a device from the patch file
	 *
	 * @param WURFL_Xml_ModelDevice $device
	 * @param WURFL_Xml_ModelDevice $patchingDevice
	 * @return WURFL_Xml_ModelDevice
	 */
	private function patchSingleDevice($device, $patchingDevice) {
		if (strcmp($patchingDevice->userAgent, $device->userAgent) !== 0) {
			$message = "Patch Device : " .$patchingDevice->id . " can't ovveride user agent " . $device->userAgent . " with " . $patchingDevice->userAgent;
			throw new WURFL_WURFLException($message);
		}
		
		$groupIdCapabilitiesMap = WURFL_WURFLUtils::array_merge_recursive_unique($device->getGroupIdCapabilitiesMap(), $patchingDevice->getGroupIdCapabilitiesMap());
		
		return new WURFL_Xml_ModelDevice($device->id, $device->userAgent, $device->fallBack, $device->actualDeviceRoot, $groupIdCapabilitiesMap);

	}