예제 #1
0
 public function __construct(\Slim\Mvc\App $app)
 {
     parent::__construct();
     $pdo = new \PDO(sprintf('mysql:host=%s;dbname=%s', $app->config('database.host'), $app->config('database.shem')), $app->config('database.user'), $app->config('database.pass'));
     $this->db = new \FluentPDO($pdo);
     $this->events()->publish('core.database.init', [$this]);
 }
예제 #2
0
파일: View.php 프로젝트: tyurderi/slim-mvc
 public function __construct()
 {
     parent::__construct();
     if (!$this->dispatcher()->dispatched()) {
         trigger_error('The view component was created before a controller was dispatched so the view component 
         probably doesn\'t work as expected.', E_USER_NOTICE);
     }
     $this->config = $this->app()->config('view');
     $this->themeName = $this->config('theme', 'default');
     $this->selectThemePath();
     $this->loader = new \Twig_Loader_Filesystem($this->dir() . $this->themePath);
     $this->twig = new \Twig_Environment($this->loader, ['autoescape' => false, 'auto_reload' => true, 'cache' => $this->dir() . $this->config['cache_path']]);
     $this->context = [];
     $this->viewName = 'index/index';
     $this->events()->publish('core.view.init', [$this]);
     $this->assign('controllerName', $this->dispatcher()->controllerName());
     $this->assign('actionName', $this->dispatcher()->actionName());
 }