/**
  * 获取Filesystem
  * @return Filesystem
  */
 public static function getFileSystem()
 {
     if (is_null(static::$driver)) {
         static::$driver = \Storage::drive('local');
     }
     return static::$driver;
 }
Example #2
0
 public static function setDriver($new_driver)
 {
     $c = 'AeriaCache' . $new_driver;
     if (class_exists($c)) {
         static::$driver = $c;
     }
 }
Example #3
0
 /**
  * Factory method.
  *
  * @static
  * @access   public
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public static function factory()
 {
     self::$defaultLifeTime = Config::get('cache.lifetime', 3600);
     $driverName = ucfirst(Config::get('cache.driver'));
     $driver = '\\Plethora\\Cache\\Drivers\\' . $driverName . 'CacheDriver';
     static::$driver = new $driver();
     Log::insert('Cache type "' . Config::get('cache.driver') . '" initialized!');
 }
Example #4
0
 public static function init($driver = null)
 {
     if ($driver == null) {
         static::$driver = new DiskFileSystemDriver();
     } elseif ($driver instanceof LocalStorageDriverInterface) {
         static::$driver = $driver;
     } else {
         throw new Exception('driver must be instance of LocalStorageDriverInterface');
     }
 }
Example #5
0
 public static function tearDownAfterClass()
 {
     static::$driver = null;
     static::$pdo = null;
     foreach (static::$tempFiles as $file) {
         if (is_file($file)) {
             unlink($file);
         }
     }
     parent::tearDownAfterClass();
 }
Example #6
0
 /**
  * Constructor.
  *
  * @access  protected
  */
 protected function __construct()
 {
     // Set current time
     static::$now = time();
     // Cache key allows us to invalidate all cache on configuration changes.
     static::$key = (Config::get('system.cache.prefix') ? Config::get('system.cache.prefix') : 'fansoro') . '-' . md5(ROOT_DIR . Fansoro::VERSION);
     // Get Cache Driver
     static::$driver = static::getCacheDriver();
     // Set the cache namespace to our unique key
     static::$driver->setNamespace(static::$key);
 }
Example #7
0
 public static function using($driver, $options = null)
 {
     $class = 'Email\\' . ucfirst(strtolower($driver));
     if (!class_exists($class)) {
         throw new Exception("[core.email] : {$driver} driver not found.");
     }
     static::$driver_name = $driver;
     static::$options = $options;
     static::$driver = new $class();
     static::$driver->onInit($options);
 }
Example #8
0
 /**
  * Create new session.
  *
  * @return void
  */
 public function __construct()
 {
     // Does the session need to be initialized?
     if (!static::$initialized) {
         // Get the driver name from the application config and get the
         // class name for us to instantiate.
         $driver = 'native';
         $class = 'Spire\\Session\\Driver\\' . ucfirst(strtolower($driver));
         // Instantiate driver.
         static::$driver = new $class();
         // Initialize the session.
         if (static::driver()->initialize()) {
             static::$initialized = true;
         }
     }
 }
Example #9
0
 /**
  * Initialize both database and forge components
  */
 public static function init($driver)
 {
     if (empty(static::$db) && empty(static::$forge)) {
         $config = Mock_Database_DB::config($driver);
         $connection = new Mock_Database_DB($config);
         $db = Mock_Database_DB::DB($connection->set_dsn($driver), TRUE);
         CI_TestCase::instance()->ci_instance_var('db', $db);
         $loader = new CI_Loader();
         $loader->dbforge();
         $forge = CI_TestCase::instance()->ci_instance_var('dbforge');
         static::$db = $db;
         static::$forge = $forge;
         static::$driver = $driver;
     }
     return static::$db;
 }
Example #10
0
 /**
  * Init, config loading.
  * @throws Amon_Request_Exception
  */
 public static function _init()
 {
     \Config::load('amon', true);
     static::$config = \Config::get('amon');
     if (!class_exists('\\ZMQContext')) {
         static::$config['protocol'] = 'http';
     }
     $class = 'Amon_Request_' . ucwords(strtolower(static::$config['protocol']));
     if (!class_exists($class)) {
         throw new Amon_Request_Exception('Can not find request driver');
     }
     try {
         static::$driver = new $class(static::$config['host'], static::$config['port'], static::$config['application_key']);
     } catch (Amon_Request_Exception $e) {
         throw $e;
     }
 }
Example #11
0
 /**
  * Load cache drivers with a FCFS strategy
  *
  * @method using
  * @param  mixed $driver can be a single driver name string, an array of driver names or a map [ driver_name => driver_options array ]
  * @return bool   true if a driver was loaded
  * @example
  *
  *   Cache::using('redis');
  *   Cache::using(['redis','files','memory']); // Prefer "redis" over "files" over "memory" caching
  *   Cache::using([
  *         'redis' => [
  *             'host'   => '127.0.0.1',
  *             'prefix' => 'mycache',
  *          ],
  *         'files' => [
  *             'cache_dir' => '/tmp',
  *         ],
  *         'memory'
  *   ]);
  *
  */
 public static function using($driver)
 {
     foreach ((array) $driver as $key => $value) {
         if (is_numeric($key)) {
             $drv = $value;
             $conf = [];
         } else {
             $drv = $key;
             $conf = $value;
         }
         $class = 'Cache\\' . ucfirst(strtolower($drv));
         if (class_exists($class) && $class::valid()) {
             static::$driver = new $class($conf);
             return true;
         }
     }
     return false;
 }
Example #12
0
 /**
  * Get the session driver.
  *
  * @return Session\Driver
  */
 public static function driver()
 {
     if (is_null(static::$driver)) {
         switch (Config::get('session.driver')) {
             case 'cookie':
                 return static::$driver = new Session\Cookie();
             case 'file':
                 return static::$driver = new Session\File();
             case 'db':
                 return static::$driver = new Session\DB();
             case 'memcached':
                 return static::$driver = new Session\Memcached();
             case 'apc':
                 return static::$driver = new Session\APC();
             default:
                 throw new \Exception("Session driver [{$driver}] is not supported.");
         }
     }
     return static::$driver;
 }
Example #13
0
 /**
  * Sets the database driver (string).
  */
 public static function setDriver($driver)
 {
     static::$driver = strtolower($driver);
 }
 /**
  * @param ILogStore $d driver to be set
  */
 public static function setDriver(ILogStore $d)
 {
     static::$driver = $d;
 }
Example #15
0
 public static function _init()
 {
     static::$driver = new \G2verify_Driver();
 }
Example #16
0
 public static function setDriver($driver)
 {
     static::$driver = $driver;
 }
 /**
  * This method is called after the last test of this test class is run.
  *
  * @return  void
  *
  * @since   12.1
  */
 public static function tearDownAfterClass()
 {
     JFactory::$database = self::$_stash;
     static::$driver = null;
 }
 public static function setUpBeforeClass()
 {
     static::$driver = \RemoteWebDriver::create('http://localhost:4444/wd/hub', array(\WebDriverCapabilityType::BROWSER_NAME => \WebDriverBrowserType::FIREFOX));
 }
Example #19
0
 public static function using($driver)
 {
     static::$driver = '\\Email\\' . ucfirst(strtolower($driver));
 }
Example #20
0
 public static function driver()
 {
     if (isset(static::$driver)) {
         return static::$driver;
     }
     $class = 'CMF\\Cache\\Driver\\' . ucfirst(\Config::get('cmf.cache.driver', 'Simple'));
     return static::$driver = new $class();
 }
Example #21
0
 /**
  * Setup simplifier for the current driver
  *
  * @param string $driver
  * @param mixed $args
  * @return Cache\Driver
  */
 public static function setup($driver, $args = null)
 {
     $ref = new ReflectionClass('Cache\\Driver\\' . $driver);
     return static::$driver = $ref->newInstanceArgs(array($args));
 }