コード例 #1
0
ファイル: TableAbstract.php プロジェクト: dez-php/dez-orm
 /**
  * @throws ORMException
  */
 public function __construct()
 {
     if (!$this->hasTable()) {
         throw new ORMException('Not defined table name for: ' . $this->getTableName());
     }
     if ($this->defineConnectionName()) {
         ORM\Connection::setConnectionName(static::$connection);
     }
     $this->setConnection(ORM\Connection::connect());
 }
コード例 #2
0
 public function configure()
 {
     /**
      * @var Config $serverConfig
      * @var Config $applicationConfig
      */
     if ($this->config->has('server')) {
         $serverConfig = $this->config->get('server');
         if ($serverConfig->has('timezone')) {
             date_default_timezone_set($serverConfig['timezone']);
         }
         if ($serverConfig->has('displayErrors')) {
             ini_set('display_errors', $serverConfig['displayErrors']);
         }
         if ($serverConfig->has('errorLevel')) {
             error_reporting($serverConfig['errorLevel']);
         }
     }
     if ($this->config->has('application')) {
         $applicationConfig = $this->config->get('application');
         if ($applicationConfig->has('autoload')) {
             $this->loader->registerNamespaces($applicationConfig->get('autoload')->toArray())->register();
         }
         if ($applicationConfig->has('controller')) {
             $this->setControllerNamespace($applicationConfig['controller']['namespace']);
         }
         if ($applicationConfig->has('base_path')) {
             $this->url->setBasePath($applicationConfig['base_path']);
             if ($applicationConfig->has('static_path')) {
                 $this->url->setStaticPath($applicationConfig['static_path']);
             }
         }
         if ($applicationConfig->has('view')) {
             $this->dependencyInjector->set('view', function () use($applicationConfig) {
                 $services = iterator_to_array($this->dependencyInjector);
                 $directory = $applicationConfig['view']['root_directory'];
                 return new Template($directory, $services);
             });
         } else {
             throw new MvcException('Required configuration for view don`ts exists');
         }
     }
     if ($this->config->has('db')) {
         Connection::init($this->config, $this->config->path('db.connection_name'));
     }
     return $this;
 }
コード例 #3
0
ファイル: init.php プロジェクト: dez-php/dez-authorizer
<?php

use Dez\Config\Config;
use Dez\DependencyInjection\Container;
use Dez\Http\Cookies;
use Dez\Http\Request;
use Dez\ORM\Connection as OrmConnection;
use Dez\Session\Adapter\Files;
include_once __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$container = Container::instance();
$container->set('request', function () {
    return new Request();
});
$container->set('session', function () {
    return new Files();
});
$container->set('cookies', function () {
    return new Cookies();
});
OrmConnection::init(Config::factory(__DIR__ . '/config/connection.json'), 'dev');