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); }
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'); } }
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)); } } } }
/** * get Item Language and replace string language * * @param string * @param array * @return string */ static function item($name, $replace = []) { // get info name and key $prop = self::engineName($name); $lang = $prop->key; // check language if (isset(self::$language[$prop->app][$prop->key])) { $lang = self::$language[$prop->app][$prop->key]; } $map_replace = ['today' => date(Config::read('App.Base.fmt_date'))]; // replace string $replace = array_merge($replace, $map_replace); foreach ($replace as $index => $text) { $i[] = '{' . $index . '}'; $t[] = $text; } $lang = str_replace($i, $t, $lang); return $lang; }
/** * get return public url * * @param string | array * @return url */ function _publicUrl($uri = '') { return HOST_NAME . Config::read('App.Base.public_folder') . '/' . ltrim(_uriString($uri), '/'); }
| Starting System Benchmark |-------------------------------------------------------------------------- */ $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)) {