Example #1
0
        throw new \FA\Exception\Bootstrap($e->getMessage());
    }
});
// Auth and ACL
$di->setShared('auth', array('className' => '\\FA\\Auth', 'arguments' => array(array('type' => 'service', 'name' => 'session'))));
$di->setShared('acl', array('className' => '\\FA\\Legacy\\Acl', 'arguments' => array(array('type' => 'service', 'name' => 'em'), array('type' => 'service', 'name' => 'auth'))));
// Caching
$di->setShared('cache_driver', function () use($config) {
    $cache_config = $config->cache->toArray();
    switch ($cache_config['cache']) {
        case 'redis':
            $cache_driver = new \Stash\Driver\Redis();
            $cache_driver->setOptions($cache_config['redis']);
            break;
        case 'memcached':
            $cache_driver = new \Stash\Driver\Memcache();
            $cache_driver->setOptions($cache_config['memcached']);
            break;
        case 'file':
            $cache_driver = new \Stash\Driver\FileSystem();
            $cache_driver->setOptions($cache_config['file']);
            break;
        default:
        case 'memory':
        case 'ephemeral':
            $cache_driver = new \Stash\Driver\Ephemeral();
            break;
    }
    // Register Stash as session handler if necessary.
    if (!$cache_driver instanceof \Stash\Driver\Ephemeral) {
        $pool = new \Stash\Pool($cache_driver);
Example #2
0
 /**
  * Return the application-configured driver.
  *
  * @return \Stash\Interfaces\DriverInterface
  */
 public static function getCacheDriver()
 {
     $di = \Phalcon\Di::getDefault();
     $config = $di->get('config');
     $cache_config = $config->cache->toArray();
     switch ($cache_config['cache']) {
         case 'redis':
             $cache_driver = new \Stash\Driver\Redis();
             $cache_driver->setOptions($cache_config['redis']);
             return $cache_driver;
             break;
         case 'memcached':
             $cache_driver = new \Stash\Driver\Memcache();
             $cache_driver->setOptions($cache_config['memcached']);
             return $cache_driver;
             break;
         case 'file':
             $cache_driver = new \Stash\Driver\FileSystem();
             $cache_driver->setOptions($cache_config['file']);
             return $cache_driver;
             break;
         default:
         case 'memory':
         case 'ephemeral':
             return new \Stash\Driver\Ephemeral();
             break;
     }
 }