예제 #1
0
 protected function __construct($config = array())
 {
     parent::__construct();
     $this->_values = new Container();
     $routerClass = Utils::checkInterfaceImplementation($config['routerClass'], 'PollExample\\RouterInterface');
     $routes = $config['routes'] ?: array();
     $this->_values['router'] = function ($c) use($routerClass, $routes) {
         return new $routerClass($routes);
     };
     $dispatcherClass = Utils::checkInterfaceImplementation($config['dispatcherClass'], 'PollExample\\DispatcherInterface');
     $this->_values['dispatcher'] = function ($c) use($dispatcherClass, $config) {
         return new $dispatcherClass($config['appDir'] . '/' . $config['controllersDir']);
     };
     $entityManagerClass = Utils::checkInterfaceImplementation($config['entityManagerClass'], 'PollExample\\EntityManagerInterface');
     $this->_values['entityManager'] = function ($c) use($entityManagerClass, $config) {
         $entityManager = new $entityManagerClass($config['db'], $config['appDir'] . '/' . $config['modelsDir'], $config['debug']);
         return $entityManager->create();
     };
     $templateEngineClass = Utils::checkInterfaceImplementation($config['templateEngineClass'], 'PollExample\\TemplateEngineInterface');
     $this->_values['templateEngine'] = function ($c) use($templateEngineClass, $config) {
         return new $templateEngineClass($config['appDir'] . '/' . $config['viewsDir']);
     };
 }
예제 #2
0
 protected function __construct($config = array())
 {
     parent::__construct();
     $this->_values = array_merge($this->_defaults, $config);
 }