Exemplo n.º 1
0
 /**
  * tests creating a MemoryStorage
  */
 public function testCreateMemoryStorage()
 {
     $configuration = array();
     $result = Factory::create($configuration);
     self::assertInstanceOf('\\Wurfl\\Storage\\Storage', $result);
     self::assertInstanceOf('\\WurflCache\\Adapter\\Memory', $result->getAdapter());
 }
Exemplo n.º 2
0
 public static function setUpBeforeClass()
 {
     $resourcesDir = self::RESOURCES_DIR;
     $cacheDir = self::CACHE_DIR;
     self::$config = new InMemoryConfig();
     self::$config->wurflFile($resourcesDir . 'wurfl.xml');
     $params = array(Config::DIR => $cacheDir, Config::EXPIRATION => 0);
     self::$config->persistence('file', $params);
     self::$config->cache('memory');
     self::$cacheStorage = Factory::create(self::$config->cache);
     self::$persistenceStorage = Factory::create(self::$config->persistence);
 }
Exemplo n.º 3
0
 /**
  * @param string|\Noodlehaus\Config $config
  *
  * @return \Wurfl\Manager
  */
 public static function factory($config)
 {
     static $instance = null;
     if (is_string($config)) {
         $config = new FileConfig($config);
     }
     if (!$config instanceof Config) {
         throw new \InvalidArgumentException('the parameter $xmlConfig has to be a path to a config file or an instance of \\Wurfl\\Configuration\\Config');
     }
     if (null === $instance) {
         // Create the cache instance from the configuration
         $cacheStorage = Storage\Factory::create($config->cache);
         // Create the persistent cache instance from the configuration
         $persistenceStorage = Storage\Factory::create($config->persistence);
         $instance = new self($config, $persistenceStorage, $cacheStorage);
     }
     return $instance;
 }
 */
$resourcesDir = '.tmp/wurfl';
$persistenceDir = $resourcesDir . '/storage/persistence';
$cacheDir = $resourcesDir . '/storage/cache';
// Create WURFL Configuration
$wurflConfig = new \Wurfl\Configuration\InMemoryConfig();
$wurflConfig->wurflFile('data/wurfl.xml');
$wurflConfig->matchMode(\Wurfl\Configuration\Config::MATCH_MODE_ACCURACY);
// save convertion
$wurflConfig->persistence('file', [\Wurfl\Configuration\Config::DIR => $persistenceDir]);
// Setup Caching
$wurflConfig->cache('file', [\Wurfl\Configuration\Config::DIR => $cacheDir]);
// Create the cache instance from the configuration
$cacheStorage = \Wurfl\Storage\Factory::create($wurflConfig->cache);
// Create the persistent cache instance from the configuration
$persistenceStorage = \Wurfl\Storage\Factory::create($wurflConfig->persistence);
// Create a WURFL Manager from the WURFL Configuration
$wurflManager = new \Wurfl\Manager($wurflConfig, $persistenceStorage, $cacheStorage);
$wurflManager->reload();
// /*
//  * APC
//  */
// $resourcesDir = '.tmp/wurfl';
// $persistenceDir = $resourcesDir . '/storage/persistence';
// $cacheDir = $resourcesDir . '/storage/cache';
// // Create WURFL Configuration
// $wurflConfig = new \Wurfl\Configuration\InMemoryConfig();
// $wurflConfig->wurflFile('data/wurfl.xml');
// $wurflConfig->matchMode(\Wurfl\Configuration\Config::MATCH_MODE_ACCURACY);
// // save convertion
// $wurflConfig->persistence('file', [