Пример #1
0
 public function __construct($env, \Phalcon\DiInterface $di = null)
 {
     /**
      * set environment
      */
     self::$env = strtolower($env);
     switch ($this::$env) {
         case self::ENV_PRODUCTION:
             ini_set('display_errors', 0);
             ini_set('display_startup_errors', 0);
             error_reporting(0);
             break;
         case self::ENV_TESTING:
         case self::ENV_DEVELOPMENT:
             ini_set('display_errors', 1);
             ini_set('display_startup_errors', 1);
             error_reporting(-1);
             break;
         default:
             throw new \Exception('Wrong application $env passed: ' . $env);
     }
     /**
      * register di
      */
     if (is_null($di)) {
         $di = new \Phalcon\DI\FactoryDefault();
     }
     /**
      * Read the configuration
      */
     $config =& $this->config;
     $config = new \Phalcon\Config(include ROOT_PATH . '/config/config.php');
     $di->set('config', $config);
     parent::__construct($di);
 }
Пример #2
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Пример #3
0
 /**
  * 设置模块
  */
 public static function bind_module($name, $path)
 {
     // 设置模块
     self::$module = $name;
     // 定义项目目录常量
     define('W_APPLICATION_PATH', $path);
     //初始化加载
     require realpath(__DIR__ . '/../bootstrap.php');
 }
 /**
         Construct the configuration and constants based on config.xml and other path diretories
         @access public
         @throws Exception object
         @static
         @return void
 */
 public static function construct_configuration_constants()
 {
     try {
         //Define ROOT_PATH
         $documentRoot = $_SERVER['DOCUMENT_ROOT'];
         //Define CONFIG_FILENAME
         self::$Configuration["file"]["config"] = 'Config.xml';
         //Set file configuration
         self::$Configuration = json_decode(json_encode((array) get_object_vars(simplexml_load_file(self::config('file->config')))), true);
         //Define ROOT_PATH
         self::$Configuration["path"]["virtual"]["root"] = self::config('router->base_url');
         self::$Configuration["path"]["physical"]["root"] = $documentRoot . self::config('path->virtual->root');
         //Define UNAUTHENTICATED_ROUTE_FILENAME
         self::$Configuration["file"]["unauthenticated_route"] = self::config('path->physical->root') . 'UnauthenticatedRoute.xml';
         //Define LIBRARY_PATH
         self::$Configuration["path"]["virtual"]["library"] = "Library/";
         self::$Configuration["path"]["physical"]["library"] = self::config('path->physical->root') . self::config('path->virtual->library');
         //Define LIRRARY_TOOLKIT_PATH
         self::$Configuration["path"]["virtual"]["toolkit"] = "Toolkit/";
         self::$Configuration["path"]["physical"]["toolkit"] = self::config('path->physical->library') . self::config('path->virtual->toolkit');
         //Define LIRRARY_DAO_PATH
         self::$Configuration["path"]["virtual"]["data_access_object"] = "DataAccessObject/";
         self::$Configuration["path"]["physical"]["data_access_object"] = self::config('path->physical->library') . self::config('path->virtual->data_access_object');
         //Define LIRRARY_VO_PATH
         self::$Configuration["path"]["virtual"]["value_object"] = "ValueObject/";
         self::$Configuration["path"]["physical"]["value_object"] = self::config('path->physical->library') . self::config('path->virtual->value_object');
         //Define LIRRARY_INTERFACE_PATH
         self::$Configuration["path"]["virtual"]["interface"] = "Interface/";
         self::$Configuration["path"]["physical"]["interface"] = self::config('path->physical->library') . self::config('path->virtual->interface');
         //Define BUSINESS_PATH
         self::$Configuration["path"]["virtual"]["business_core"] = "BusinessCore/";
         self::$Configuration["path"]["physical"]["business_core"] = self::config('path->physical->library') . self::config('path->virtual->business_core');
         //Define SERVICE_PATH
         self::$Configuration["path"]["virtual"]["service"] = "Service/";
         self::$Configuration["path"]["physical"]["service"] = self::config('path->physical->library') . self::config('path->virtual->service');
     } catch (Exception $e) {
         throw $e;
     }
 }