Example #1
0
 /**
  * @return void
  * @uses \Event
  * @uses \EventHandler
  * @uses \DI
  * @uses \DataFilter
  * @todo get teacher for mysql in GlobalEvents for Crontab
  */
 public static function startup()
 {
     $cronevent = new \Event('cron.run');
     $cronevent->call(function () {
         // do something
     });
     \EventHandler::attach($cronevent);
     $cronevent = new \Event('crontab.run.untis');
     $cronevent->call(function () {
         //do something
     });
     \EventHandler::attach($cronevent);
 }
Example #2
0
 /**
  * get started with all this
  * @return void
  * @todo template-map
  */
 public static function startup()
 {
     $activeTemplate = new Template(app::get('template'));
     $gettext = new Gettext(HOME_DIR . '/locale/' . app::get('language') . '.mo');
     if ($activeTemplate->translated) {
         Gettext::addTranslation(HOME_DIR . '/templates/' . app::get('template') . '/locale/' . app::get('language') . '.mo');
     }
     require_once HOME_DIR . '/translate_functions.php';
     if (isset($activeTemplate->map)) {
         foreach ($activeTemplate->map as $map) {
             Route::get("/{$map}/[fn:filename]", "AssetsController.everything")->name($map);
         }
     }
     // add your routes here!
     Route::get('/^\\s*$/', 'IndexController.get', true);
     Route::get('/test/stack', 'TestController.stack');
     Route::get('/css/[fn:filename]', 'AssetsController.css');
     Route::get('/js/[fn:filename]', 'AssetsController.js');
     Modules::loadModuleList();
     Modules::loadModules();
     //$msqlo = new MySQLi(app::get('mysql')->host, app::get('mysql')->user, app::get('mysql')->password, app::get('mysql')->database);
     //\DI::addInstance($msqlo);
     $modelob = new \Observer\ModelObserver();
     \DI::addInstance($modelob);
     $etagevent = new \Event('etag.change');
     $etagevent->call(function ($newval) {
         \Kernel::$response->etag = md5(\Kernel::$response->etag . '|' . $newval);
     });
     \EventHandler::attach($etagevent);
     Route::registerNotFoundAction('/', function () {
         \Kernel::$response->errorCode(404);
         (new \Controller())->view('error', ['error' => ['code' => '404', 'text' => 'Not found!']]);
     });
     Route::registerNotFoundAction('/api/', function () {
         throw new \HTTPException\ObjectNotFoundException(404, "Requested resource not found!");
     });
 }