Beispiel #1
0
 public function __construct()
 {
     if (func_num_args() > 0) {
         $config = func_get_arg(0);
         $this->setConfig($config);
     }
     Loader::getClass('Sky.core.Log')->write(100, get_class($this) . ' Class Initialize');
 }
Beispiel #2
0
 function __construct($conf = [])
 {
     parent::__construct($conf);
     $this->uri = Loader::getClass('Sky.core.URI');
     $this->method = $this->getConfig('default_method');
     $this->setClass($this->getConfig('default_controller'));
     if (!$this->class) {
         Exceptions::showError("Server Error", "Unable to determine what should be displayed. A default route has not been specified in the routing file.");
         exit;
     }
     $this->_initialize();
 }
Beispiel #3
0
 function __construct(array $params = [], Configuration $config = null, EventManager $eventManager = null)
 {
     if (!$params) {
         Config::load('App.DB');
         $params = Config::read('App.DB.connect');
     }
     parent::__construct();
     $this->db = DriverManager::getConnection($params, new Configuration());
     if ($this->db->connect()) {
         Loader::getClass('Sky.core.Log')->write(100, 'database connected');
     }
 }
Beispiel #4
0
 /**
  * Load file language
  * 
  * @param string
  * @return void
  */
 static function load($name)
 {
     $lang = Config::read('App.Base.language');
     $prop = Loader::getName($name, 'locale' . DS . $lang);
     // if file already loaded? if so done!
     if (isset(self::$language[$prop->app])) {
         return self::$language[$prop->app];
     }
     // is file not exists?
     if (!file_exists($prop->path)) {
         user_error('Language Not Found ' . $prop->path);
         exit;
     }
     self::$language[$prop->app] = (require_once $prop->path);
 }
Beispiel #5
0
 /**
  * load file config
  * 
  * @param string
  * @return array
  */
 static function load($name)
 {
     if ($name == '') {
         return self::$data;
     }
     $name = Loader::getName($name, 'config');
     $key = $name->app . '.' . $name->class;
     if (!isset(static::$data[$key])) {
         // file config is exist?
         if (!file_exists($name->path)) {
             user_error('Config ' . $name->path . ' Not Found');
             exit;
         }
         self::$data[$key] = (require_once $name->path);
     }
     return self::$data[$key];
 }
Beispiel #6
0
 /**
  * Load View File
  * 
  * @param string
  * @param array
  * @param boolean
  * @return void|html;
  */
 public static function load($_sky_name, $_sky_var = [], $_sky_return = false)
 {
     $__prop = Loader::getName($_sky_name, 'view');
     if (!file_exists($__prop->path)) {
         Exceptions::showError('Server Error', 'Missing View File: ' . $__prop->path);
         return;
     }
     // extract array to variable
     extract($_sky_var);
     ob_start();
     include $__prop->path;
     $__view = ob_get_contents();
     ob_end_clean();
     if ($_sky_return) {
         return $__view;
     }
     self::$temp .= $__view;
 }
Beispiel #7
0
|--------------------------------------------------------------------------
*/
$BM = Loader::getClass('Sky.core.Benchmark');
$BM->mark('start_sky');
/*
|--------------------------------------------------------------------------
| initialize prase URI and Router
|--------------------------------------------------------------------------
*/
Config::load('App.Routes');
$RTR = Loader::getClass('Sky.core.Router', Config::read('App.Routes'));
$class = ucfirst($RTR->class);
$method = $RTR->method;
$OUT = Loader::getClass('Sky.core.Output');
if (Config::read('App.Base.enable_cache')) {
    $CH = Loader::getClass('Sky.core.Cache');
    if ($CH_OUT = $CH->read(implode($RTR->segments, '.'))) {
        $OUT->append(View::getTemp());
        $LOG->write(100, 'Cache Rendered');
        goto OUTPUT;
    }
}
/*
|--------------------------------------------------------------------------
| Starting Controller Benchmark
|--------------------------------------------------------------------------
*/
$BM->mark('start_controller');
$PATH = $RTR->getPath();
if (!file_exists($PATH)) {
    Exceptions::show404();
Beispiel #8
0
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
$AutoLoad = (require VENDOR_PATH . DS . 'autoload.php');
/*
|--------------------------------------------------------------------------
| Add Register psr4 for Application folder
|--------------------------------------------------------------------------
*/
//$AutoLoad->setPsr4('App\\', APP_PATH);
/*
|--------------------------------------------------------------------------
| Add Register psr4 for Sky folder
|--------------------------------------------------------------------------
*/
//$AutoLoad->setPsr4('Sky\\', VENDOR_PATH . 'sky' . DS . 'framework' . DS . 'src');
/*
|--------------------------------------------------------------------------
| Register Instance Loader Class
|--------------------------------------------------------------------------
|
| Register Autoload Composer Class to instance class.
|
*/
Loader::addInstance($AutoLoad);