/** * tests Clearing the cache */ public function testClear() { $params = array('dir' => 'abc'); $this->root->save('Test', $params); $this->root->clear(); self::assertNull($this->root->load('Test')); }
/** * Saves the classified user agents in the persistence provider */ public function persistData() { // we sort the array first, useful for doing ris match if (!empty($this->userAgentsWithDeviceID)) { ksort($this->userAgentsWithDeviceID); $this->persistenceProvider->save($this->getPrefix(), $this->userAgentsWithDeviceID); $this->persistenceProvider->save($this->getPrefix(self::PREFIX_OVERWRITTEN), $this->overwritten_devices); $this->persistenceProvider->save($this->getPrefix(self::PREFIX_UA_BUCKET), array_keys($this->userAgentsWithDeviceID)); } }
/** * Save given $device in the persistence provider. This is called when loading the WURFL XML * data, directly after reading the complete device node. * * @param \Wurfl\Device\ModelDeviceInterface $device * * @see \Wurfl\Handlers\Chain\UserAgentHandlerChain::filter(), WURFL_Storage_Base::save() */ private function classifyAndPersistDevice(ModelDeviceInterface $device) { if ($this->validateDevice($device) === false) { return; } array_push($this->devices, $device->id); if ($device->fallBack !== 'root') { $this->fallbacks[$device->fallBack] = $device->id; } $this->userAgentHandlerChain->filter($device->userAgent, $device->id); $this->persistenceProvider->save($device->id, $device); }
/** * Create a \Wurfl\Handlers\Chain\UserAgentHandlerChain * * @param \Wurfl\Storage\Storage $persistenceProvider * @param \Wurfl\Storage\Storage $cacheProvider * @param \Psr\Log\LoggerInterface $logger * * @return UserAgentHandlerChain */ public static function createFrom(Storage $persistenceProvider, Storage $cacheProvider, LoggerInterface $logger = null) { /** @var $userAgentHandlerChain \Wurfl\Handlers\Chain\UserAgentHandlerChain */ $userAgentHandlerChain = $cacheProvider->load('UserAgentHandlerChain'); if (!$userAgentHandlerChain instanceof UserAgentHandlerChain) { $userAgentHandlerChain = self::init(); $cacheProvider->save('UserAgentHandlerChain', $userAgentHandlerChain, 3600); } $userAgentHandlerChain->setLogger($logger); foreach ($userAgentHandlerChain->getHandlers() as $handler) { /* @var $handler \Wurfl\Handlers\AbstractHandler */ $handler->setLogger($logger)->setPersistenceProvider($persistenceProvider); } return $userAgentHandlerChain; }