diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-12-27 19:10:38 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-12-27 19:10:38 -0500 |
commit | 17dc5bdc9ede52ad618bbf326e67e3b6988170f7 (patch) | |
tree | 9cf4d325667f11fa735bca84042fb385e3273329 /app/ServiceProvider/Database.php | |
parent | cf821e117ce8b937cff7f386a107aaa81ba6bf9b (diff) |
Move events handling to Symfony\EventDispatcher
Diffstat (limited to 'app/ServiceProvider/Database.php')
-rw-r--r-- | app/ServiceProvider/Database.php | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/app/ServiceProvider/Database.php b/app/ServiceProvider/Database.php deleted file mode 100644 index 75e1f73e..00000000 --- a/app/ServiceProvider/Database.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php - -namespace ServiceProvider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use PicoDb\Database as Dbal; - -class Database implements ServiceProviderInterface -{ - public function register(Container $container) - { - $container['db'] = $this->getInstance(); - } - - /** - * Setup the database driver and execute schema migration - * - * @return PicoDb\Database - */ - public function getInstance() - { - switch (DB_DRIVER) { - case 'sqlite': - $db = $this->getSqliteInstance(); - break; - - case 'mysql': - $db = $this->getMysqlInstance(); - break; - - case 'postgres': - $db = $this->getPostgresInstance(); - break; - - default: - die('Database driver not supported'); - } - - if ($db->schema()->check(\Schema\VERSION)) { - return $db; - } - else { - $errors = $db->getLogMessages(); - die('Unable to migrate database schema: <br/><br/><strong>'.(isset($errors[0]) ? $errors[0] : 'Unknown error').'</strong>'); - } - } - - /** - * Setup the Sqlite database driver - * - * @return PicoDb\Database - */ - function getSqliteInstance() - { - require_once __DIR__.'/../Schema/Sqlite.php'; - - return new Dbal(array( - 'driver' => 'sqlite', - 'filename' => DB_FILENAME - )); - } - - /** - * Setup the Mysql database driver - * - * @return PicoDb\Database - */ - function getMysqlInstance() - { - require_once __DIR__.'/../Schema/Mysql.php'; - - return new Dbal(array( - 'driver' => 'mysql', - 'hostname' => DB_HOSTNAME, - 'username' => DB_USERNAME, - 'password' => DB_PASSWORD, - 'database' => DB_NAME, - 'charset' => 'utf8', - )); - } - - /** - * Setup the Postgres database driver - * - * @return PicoDb\Database - */ - public function getPostgresInstance() - { - require_once __DIR__.'/../Schema/Postgres.php'; - - return new Dbal(array( - 'driver' => 'postgres', - 'hostname' => DB_HOSTNAME, - 'username' => DB_USERNAME, - 'password' => DB_PASSWORD, - 'database' => DB_NAME, - )); - } -} |