Ejemplo n.º 1
0
 public function __construct($config, $type)
 {
     if (is_string($config)) {
         $config = (require $config);
     }
     if (isset($config['app_path'])) {
         $this->setBasePath($config['app_path']);
         Base::setAppPath($config['app_path']);
         Loader::setPathOfAlias('app', Base::getAppPath());
         Loader::setPathOfAlias('public', dirname($_SERVER['SCRIPT_FILENAME']));
         unset($config['app_path']);
     } else {
         throw new Exception('Application: missing application\'s config "app_path"');
     }
     if (!isset($config['namespace'])) {
         throw new Exception('Application: missng config "namespace"');
     }
     Loader::addNamespace($config['namespace'], dirname(Base::getAppPath()));
     $this->setAppNamespace($config['namespace']);
     if (isset($config['import'])) {
         $this->_import($config['import']);
         unset($config['import']);
     }
     $this->_type = $type;
     $this->preInit();
     $this->configuration($config);
     $this->_init();
     $this->afterInit();
     /**
      * @TODO removed since version 1.0.2, application custom error handler
      */
     //        set_error_handler(array($this,'handleError'),error_reporting());
 }