コード例 #1
0
ファイル: FactoryTest.php プロジェクト: mimmi20/wurfl
 /**
  * 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());
 }
コード例 #2
0
ファイル: ManagerTest.php プロジェクト: mimmi20/wurfl
 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);
 }
コード例 #3
0
ファイル: Manager.php プロジェクト: mimmi20/wurfl
 /**
  * @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;
 }
コード例 #4
0
 */
$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', [