示例#1
0
 function __call($key, $params)
 {
     if (!method_exists($this->db, $key)) {
         Exceptions::showError('Database Error', $key . ' Method Not Exists');
     }
     return call_user_func_array([$this->db, $key], $params);
 }
示例#2
0
 function __construct()
 {
     parent::__construct();
     Config::load('App.DB');
     $entityType = 'Create' . ucfirst(Config::read('App.DB.entity.type')) . 'Configuration';
     if (!method_exists($setup = new Setup(), $entityType)) {
         Exceptions::showError('Server Error', 'Invalid Entity Type use Annotation, XML or YAML');
     }
     $this->config = $setup->{$entityType}(Config::read('App.DB.entity.path'), true);
     $this->em = EntityManager::create(Config::read('App.DB.connect'), $this->config);
 }
示例#3
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();
 }
示例#4
0
 /**
 Load Files
 
 @param string
 @param string
 */
 static function load($namespace, $folder = '')
 {
     if (!isset(self::$files[$namespace])) {
         $ns = self::getName($namespace, $folder);
         if (!file_exists($ns->path)) {
             Exceptions::showError('Server Error', 'Missing File ' . $ns->path . ' Not Found');
             exit;
         }
         require_once $ns->path;
         self::$files[$namespace] = $ns;
     }
 }
示例#5
0
 function __construct($name = 'SKY')
 {
     $date = date(Config::read('App.Base.log_split_time'));
     $path = Config::read('App.Base.log_path');
     if (!is_dir($path)) {
         Exceptions::showError('Server Error', 'Missing Log Folder. to fix this error, create folder at ' . $path);
     }
     if (is_array($log_file = Config::read('App.Base.log_filename'))) {
         foreach (Config::read('App.Base.log_filename') as $level => $file) {
             if (in_array($level, Config::read('App.Base.enable_log'))) {
                 $this->log[$level] = new Logger($name);
                 $this->log[$level]->pushHandler(new StreamHandler($path . $date . ' ' . $file, $level));
             }
         }
     }
 }
示例#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;
 }
示例#7
0
/*
|--------------------------------------------------------------------------
| Parse possibility namespace and class 
|--------------------------------------------------------------------------
*/
$nsclass = [$class, DS . 'App' . DS . 'controller' . DS . $class, $ns . $class];
foreach ($nsclass as $name) {
    if (class_exists($name)) {
        $class = $name;
        break;
    }
}
$SKY = new $class();
if (!method_exists($SKY, '__init') or !method_exists($SKY, '__output')) {
    $LOG->write(500, $class . ' Missing Method __init or __output');
    Exceptions::showError('Server Error', 'Missing Method __init or __output');
}
/*
|--------------------------------------------------------------------------
| Start Running Controller
|--------------------------------------------------------------------------
*/
$SKY->__init($method, array_slice($RTR->segments, 2));
/*
|--------------------------------------------------------------------------
| Render Output Controller
|--------------------------------------------------------------------------
*/
OUTPUT:
if (isset($SKY)) {
    $SKY->__output(View::getTemp());