summaryrefslogtreecommitdiff
path: root/app/functions.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-14 22:44:25 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-14 22:44:25 -0500
commitb081288188bb1744c9d7bd075aa5936e0ccbb9c4 (patch)
tree68008e35eb129f74b9b2a49f6f6076ed02b601c6 /app/functions.php
parent1487cb27634161ef558c367150213bc7077e4198 (diff)
Use Pimple instead of Core\Registry and add Monolog for logging
Diffstat (limited to 'app/functions.php')
-rw-r--r--app/functions.php135
1 files changed, 0 insertions, 135 deletions
diff --git a/app/functions.php b/app/functions.php
index 5fe218ce..d45e78e7 100644
--- a/app/functions.php
+++ b/app/functions.php
@@ -1,141 +1,6 @@
<?php
-use Core\Event;
use Core\Translator;
-use PicoDb\Database;
-
-/**
- * Send a debug message to the log files
- *
- * @param mixed $message Variable or string
- */
-function debug($message)
-{
- if (! is_string($message)) {
- $message = var_export($message, true);
- }
-
- error_log($message.PHP_EOL, 3, 'data/debug.log');
-}
-
-/**
- * Setup events
- *
- * @return Core\Event
- */
-function setup_events()
-{
- return new Event;
-}
-
-/**
- * Setup the mailer according to the configuration
- *
- * @return Swift_SmtpTransport
- */
-function setup_mailer()
-{
- switch (MAIL_TRANSPORT) {
- case 'smtp':
- $transport = Swift_SmtpTransport::newInstance(MAIL_SMTP_HOSTNAME, MAIL_SMTP_PORT);
- $transport->setUsername(MAIL_SMTP_USERNAME);
- $transport->setPassword(MAIL_SMTP_PASSWORD);
- $transport->setEncryption(MAIL_SMTP_ENCRYPTION);
- break;
- case 'sendmail':
- $transport = Swift_SendmailTransport::newInstance(MAIL_SENDMAIL_COMMAND);
- break;
- default:
- $transport = Swift_MailTransport::newInstance();
- }
-
- return $transport;
-}
-
-/**
- * Setup the database driver and execute schema migration
- *
- * @return PicoDb\Database
- */
-function setup_db()
-{
- switch (DB_DRIVER) {
- case 'sqlite':
- $db = setup_sqlite();
- break;
-
- case 'mysql':
- $db = setup_mysql();
- break;
-
- case 'postgres':
- $db = setup_postgres();
- 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 setup_sqlite()
-{
- require_once __DIR__.'/Schema/Sqlite.php';
-
- return new Database(array(
- 'driver' => 'sqlite',
- 'filename' => DB_FILENAME
- ));
-}
-
-/**
- * Setup the Mysql database driver
- *
- * @return PicoDb\Database
- */
-function setup_mysql()
-{
- require_once __DIR__.'/Schema/Mysql.php';
-
- return new Database(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
- */
-function setup_postgres()
-{
- require_once __DIR__.'/Schema/Postgres.php';
-
- return new Database(array(
- 'driver' => 'postgres',
- 'hostname' => DB_HOSTNAME,
- 'username' => DB_USERNAME,
- 'password' => DB_PASSWORD,
- 'database' => DB_NAME,
- ));
-}
/**
* Translate a string