/** * Adds the pair $userAgent, $deviceID to the clusters they belong to. * * @param string $userAgent * @param string $deviceID * * @see \Wurfl\Handlers\AbstractHandler::filter() */ public function filter($userAgent, $deviceID) { Utils::reset(); $genericNormalizer = UserAgentHandlerChainFactory::createGenericNormalizers(); $userAgent = $genericNormalizer->normalize($userAgent); $handlers = $this->getHandlers(); foreach ($handlers as $handler) { /** @var $handler \Wurfl\Handlers\AbstractHandler */ $handler->setLogger($this->logger); if ($handler->filter($userAgent, $deviceID)) { break; } } }
/** * Wraps the model device with \Wurfl\Xml\ModelDeviceInterface. This function takes the * Device ID and returns the \Wurfl\CustomDevice with all capabilities. * * @param string $deviceId * @param Request\GenericRequest $request * * @return \Wurfl\CustomDevice */ private function getWrappedDevice($deviceId, Request\GenericRequest $request = null) { $modelDevices = $this->getCacheStorage()->load('DEVS_' . $deviceId); if (empty($modelDevices)) { $modelDevices = $this->getDeviceRepository()->getDeviceHierarchy($deviceId); } $this->getCacheStorage()->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 GenericRequestFactory(); $request = $requestFactory->createRequestForUserAgent($modelDevices[0]->userAgent); $genericNormalizer = UserAgentHandlerChainFactory::createGenericNormalizers(); $request->setUserAgentNormalized($genericNormalizer->normalize($request->getUserAgent())); } // The CustomDevice is not cached since virtual capabilities must be recalculated // for every different request. return new CustomDevice($modelDevices, $request); }