/** * start all registered classes * @return void */ public static function go() { foreach (self::$startup as $classname) { $classname::startup(); } foreach (self::$DIstartup as $classname) { \DI::getInstanceOf($classname)->startup(); } }
/** * @param string $path * @return void */ public function go($path) { $this->cache = \DI::getInstanceOf('Cache', ['css']); if ('css' == self::$prefered) { $out = $this->css($path); if (!$out) { $out = $this->less($path); } } else { $out = $this->less($path); if (!$out) { $out = $this->css($path); } } if (!$out) { $this->response->errorCode(404)->out(sprintf("<h1>%s!</h1>", __('File not found'))); } }
/** * @param string $path * @return void */ public function go($path) { $this->cache = \DI::getInstanceOf('Cache', ['js']); $inputfile = HOME_DIR . '/templates/' . \App::get('template') . '/js/' . $path; $this->cache->sendHeaders($inputfile); if ($data = $this->cache->get($inputfile)) { $this->response->setMIME('application/javascript')->out($data); } else { $file = new \File($inputfile); if ($file->exists()) { $data = \JSMin::minify($file->get()); $this->cache->set($inputfile, $data); $this->response->setMIME('application/javascript')->out($data); } else { $this->response->errorCode(404)->out(sprintf("<h1>%s!</h1>", __("File not found"))); } } }
function exception_handler($e) { header('HTTP\\1.1 500 Internal Server Error', true, 500); if (App::get('debug') || is_subclass_of($e, 'HTTPException') && \App::get('mode') == "server") { header('Content-Type: text/plain'); print $e; } elseif (\App::get('mode') == "server") { if (\App::get('mode') == "server") { header('Content-Type: text/html'); } ?> <h1> HTTP 500 Error </h1> <p>The requested page does not work properly.</p> <p>The webmaster was informed about this malfunction!<p> <?php } elseif (\App::get('mode') == "raw") { print $e; } if (class_exists('Logger') && class_exists('Logger\\MainLogger')) { \DI::getInstanceOf('Logger\\MainLogger')->log($e); } return false; }
/** * runs every middleware * @param array $args * @return bool */ private function runMiddlewares(array $args) { foreach ($this->middlewares as $mwArray) { $middleware = $mwArray[0]; $required = $mwArray[1]; $object = \DI::getInstanceOf($middleware); $result = $object->run($args, $required); if ($result == false && $required == true) { return false; } } return true; }
public function __construct() { $observer = \DI::getInstanceOf('\\Observer\\ModelObserver'); $this->addObserver($observer); }
/** * @return string */ public function __toString() { \DI::getInstanceOf('Request')->errorCode($this->code)->setMIME('application/json'); return \JSON::encode($this->jsonArray, JSON_PRETTY_PRINT); }
/** * @param array $args * @return mixed */ function DI(...$args) { $instance = \DI::getInstanceOf(...$args); return $instance; }
public function get(...$args) { return \DI::getInstanceOf($this->class, $args); }