示例#1
0
 /**
  * 
  * @param type $config
  */
 public function __construct($config = null)
 {
     \Loader::addNamespacePath('CMS\\', __DIR__ . '/../src/CMS');
     Service::set('configuration', function () {
         return new \Framework\Configuration();
     });
     Service::get('configuration')->loadFile($config);
     Service::set('db', function () {
         return new \Framework\Connection(Service::get('configuration')->get('pdo'));
     });
     Service::set('router', function () {
         return new \Framework\Router\Router(Service::get('configuration')->get('routes'));
     });
     Service::set('request', function () {
         return new \Framework\Request\Request();
     });
     Service::set('security', function () {
         return new \Framework\Security\Security();
     });
     Service::set('session', function () {
         return new \Framework\Session\Session();
     });
     Service::set('renderer', function () {
         return new \Framework\Renderer\Renderer(Service::get('configuration')->get('main_layout'));
     });
     Service::get('session');
 }
示例#2
0
 private function _initComponents()
 {
     $components = Service::getConfig('components');
     foreach ($components as $component) {
         \Loader::addNamespacePath($component['namespace'], $component['path']);
         if (isset($component['bootstrap']) && $component['bootstrap'] === 'on') {
             $class = $component['class'];
             Service::set($component['name'], new $class());
         }
     }
 }