Example #1
0
        $config = new \Doctrine\DBAL\Configuration();
        return \Doctrine\DBAL\DriverManager::getConnection($db_conf['conn'], $config);
    } catch (\Exception $e) {
        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;
    }
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;
     }
 }