classes/bfw/Configuration.php
author Markus Bröker<broeker.markus@googlemail.com>
Sat, 12 Dec 2015 12:36:24 +0100
changeset 28 29a3e34acf64
parent 21 4d61a248fd41
child 31 3a5ee3ba6006
permissions -rw-r--r--
Umstellung auf Netbeans: Quellcode mit NB neu formatiert

<?php

/**
 * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
 *
 */

namespace bfw;

use PDO;

class Configuration {

    /**
     * Standard-Autoloader für die Basis-Klassen des Projekts
     *
     * @param $class
     * @return bool
     */
    public static function bfw_autoLoader($class) {
        $nsClass = str_replace('\\', '/', $class);
        $filename = sprintf('%s/classes/%s.php', BFW_PATH, $nsClass);
        $classPath = sprintf('classes/%s.php', $nsClass);

        if (file_exists($filename)) {
            require_once BFW_PATH . "/$classPath";

            return true;
        }

        return false;
    }

    /**
     * Standard Konfiguration für den Logger
     *
     * @return array
     */
    public static function bfw_loggerConfiguration() {
        return array(
            'rootLogger' => array('appenders' => array('default')),
            'appenders' => array(
                'default' => array(
                    'class' => 'LoggerAppenderFile',
                    'layout' => array('class' => 'LoggerLayoutSimple'),
                    'params' => array(
                        'file' => BFW_PATH . '/logs/bfw.log',
                        'append' => true
                    )
                )
            )
        );
    }

    /**
     * Standard Konfiguration für den PDO-Treiber
     *
     * @return array
     */
    public static function getDataSourceProperties() {
        $dataSources = array(
            'psql' => array(
                'dsn' => 'pgsql:host=localhost;dbname=bfw',
                'config' => array(),
                'username' => 'bfw',
                'password' => 'bfw',
            ),
            'mysql' => array(
                'dsn' => 'mysql:host=localhost;dbname=bfw',
                'config' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'),
                'username' => 'bfw',
                'password' => 'bfw',
            )
        );

        return $dataSources['mysql'];
    }

}