Пример #1
0
 public function __construct()
 {
     $this->db = \Framework\Core\Database::getInstance(\Framework\Config\DatabaseConfig::DB_INSTANCE);
     $this->httpContext = new \Framework\Core\HttpContext();
 }
 function __construct()
 {
     $this->db = \Framework\Core\Database::getInstance();
 }
        $areaName = $areaParams[3];
    }
} catch (\Framework\Core\Exceptions\RouteNotFoundException $e) {
    if ($router->isActionRegistered($controller, $action)) {
        header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
        include "ErrorPages/404.php";
        die;
    }
}
if ($controller == '' || $controller == false) {
    $controller = 'home';
}
if ($action == '' || $action == false) {
    $action = 'index';
}
\Framework\Core\Database::setInstance(\Framework\Config\DatabaseConfig::DB_INSTANCE, \Framework\Config\DatabaseConfig::DB_DRIVER, \Framework\Config\DatabaseConfig::DB_USER, \Framework\Config\DatabaseConfig::DB_PASS, \Framework\Config\DatabaseConfig::DB_NAME, \Framework\Config\DatabaseConfig::DB_HOST);
//create tables if they dont exist
$dbMapper = new \Framework\Core\MappedObject();
foreach (\Framework\Config\Config::APPLICATION_MODELS as $model) {
    $tableName = array_pop(explode("\\", $model));
    if (!$dbMapper->TableExists(strtolower($tableName))) {
        $dbMapper->MapClassToDbTable($model, $tableName);
        if ($tableName == \Framework\Config\Config::ROLE_CLASS) {
            foreach (\Framework\Config\Config::USER_ROLES as $role) {
                $strClass = \Framework\Config\Config::MODEL_NAMESPACE . \Framework\Config\Config::ROLE_CLASS;
                $roleClass = new $strClass();
                $res = $roleClass->Create(\Framework\Config\Config::ROLE_CLASS, array("role" => $role));
                $res->save();
            }
        }
    }