Пример #1
0
 private function init()
 {
     Registry::init();
     $this->displayErrors();
     //this method has to be called before instantiating the autoloader because it's not namespaced
     $this->enableLoggers();
     //this method has to be called before instantiating the autoloader because it's not namespaced
     $this->initTwig();
     $this->initAutoloader();
     $this->initErrorHandler();
     $this->initExceptionHandler();
     $this->startController();
 }
Пример #2
0
 /**
  * 运行一个请求生命周期
  * @access public
  * @author songdengtao <http://www.songdengtao.cn>
  * @return void
  */
 public static function run()
 {
     // 系统注册表
     Registry::init(static::get('registryPath'));
     // 运行环境检查
     static::checkEnv();
     // 类文件自动加载
     Autoloader::init(static::getInstance());
     Autoloader::autoload();
     // 设置系统时区
     static::shell('Dtime::setDateDefaultTimeZone');
     // 设置错误处理方法
     static::shell('Error::registerShutdownFunction');
     static::shell('Error::setErrorHandler');
     // 设置异常处理方法
     static::shell('Exception::setExceptionHandler');
     if (false === static::get('isCli')) {
         static::shell('Filter::globalFilter');
         static::shell('Session::start');
     }
     // 路由
     static::shell('Router::dispatch');
     $controller = CONTROLLER_NAME . 'Controller';
     $action = ACTION_NAME . 'Action';
     $class = CONTROLLER_NAMESPACE . '\\' . $controller;
     if (!class_exists($class)) {
         $class = CONTROLLER_NAMESPACE . '\\EmptyController';
         if (!class_exists($class)) {
             $module = strstr(CONTROLLER_NAMESPACE, '\\', true);
             if (static::get('debug')) {
                 if (!is_dir(static::get('appPath') . $module)) {
                     static::shell('Error::halt', 'Call to undefined module ' . $module);
                 } else {
                     static::shell('Error::halt', 'Call to undefined controller ' . $class);
                 }
             } else {
                 static::shell('Error::halt', '404 Not found');
             }
         }
     }
     (new $class())->{$action}();
     return;
 }
Пример #3
0
 function __constructLinkedModel($assoc, $className = null)
 {
     if (empty($className)) {
         $className = $assoc;
     }
     if (!isset($this->{$assoc}) || $this->{$assoc}->name !== $className) {
         $model = array('class' => $className, 'alias' => $assoc);
         if (PHP_VERSION >= 5) {
             $this->{$assoc} = Registry::init($model);
         } else {
             $this->{$assoc} =& Registry::init($model);
         }
     }
 }
Пример #4
0
<?php

$CFG->load('database');
$DB = Mysql::init($CFG->get('mysql_host'), $CFG->get('mysql_user'), $CFG->get('mysql_password'), $CFG->get('mysql_database'));
$DB->set_names();
Registry::init()->set('DB', $DB);
$CFG->unload('database');
Пример #5
0
<?php

//Object Factory
require_once dirname(__FILE__) . "/model/core/Factory.php";
require_once dirname(__FILE__) . "/model/core/Autoloader.php";
$autloader = new model\core\Autoloader();
$autloader->register();
Factory::init();
Controller::boot();
Registry::init();
Cache::init();
Registry::loadDBSettings();
FrameEx::init();
Factory::attachAutoloader($autloader);
//boot the app
Factory::boot(APP_DIR);
Пример #6
0
function assign($key, $value)
{
    return Registry::init()->smarty->assign($key, $value);
}
Пример #7
0
// setam caile de acces catre system, fisierele de configuratie si module
define('SYSPATH', BASEPATH . 'system' . DS);
define('CFGPATH', APPPATH . 'config' . DS);
define('MODPATH', BASEPATH . 'modules' . DS);
define('PLUGINPATH', BASEPATH . 'plugins' . DS);
require SYSPATH . 'autoload.php';
// setam ca functia implicita sa fie metoda load din clasa Autoload
spl_autoload_register();
spl_autoload_register(array('Autoload', 'load'));
// deschidem sesiunea
Session::start('metin2fw');
// functii globale facute de utilizator (programator)
require SYSPATH . 'functions.php';
require SYSPATH . 'constants.php';
//
$CFG = Config::init();
$REG = Registry::init();
// includem declararea bazei de date
require SYSPATH . 'database.php';
// wrapper pentru metodele claselor
require SYSPATH . 'wrapper.php';
// Functii ce ne ajut sa lucram cu smarty
require SYSPATH . 'smarty.php';
// pre-config
set_sitename($CFG->get('site_name'));
$smarty->assign('keywords', $CFG->get('site_keywords'));
$smarty->assign('site_description', $CFG->get('site_description'));
$smarty->assign('site_lang', $CFG->get('site_lang'));
$smarty->assign('base_href', site_url());
$smarty->assign('banners', $CFG->get('banners'));
date_default_timezone_set($CFG->get('default_timezone'));