Ejemplo n.º 1
0
 public function createConnection($config)
 {
     $driver = $this->driver_manager->driver(array_get($config, 'driver', ''));
     if (!$driver instanceof \Doctrine\DBAL\Driver) {
         $driver = $this->driver_manager->driver();
     }
     $params = $config;
     $params['host'] = array_get($params, 'host', array_get($config, 'server'));
     $params['user'] = array_get($params, 'user', array_get($config, 'username'));
     $params['wrapperClass'] = array_get($config, 'wrapperClass', '\\Concrete\\Core\\Database\\Connection\\Connection');
     unset($params['driver']);
     $wrapperClass = 'Doctrine\\DBAL\\Connection';
     if (isset($params['wrapperClass'])) {
         if (is_subclass_of($params['wrapperClass'], $wrapperClass)) {
             $wrapperClass = $params['wrapperClass'];
         } else {
             throw DBALException::invalidWrapperClass($params['wrapperClass']);
         }
     }
     return new $wrapperClass($params, $driver);
 }
Ejemplo n.º 2
0
 public function testConfigLoad()
 {
     $this->driverManager->configExtensions(array('test' => 'DriverManagerTest'));
     $this->assertInstanceOf('DriverManagerTest', $this->driverManager->driver('test'));
 }