Esempio n. 1
0
 /**
  * Main function
  * Launches core classes of the framework
  * @static
  */
 public static function run()
 {
     date_default_timezone_set('UTC');
     Autoloader::register(ROOT, LIB, DOCTRINE);
     // Register contraint classes to use in the annotations of controllers
     Addendum::registerNamespaces('Cognosys\\Constraints');
     Config::load(CONFIG . 'main.yml');
     if (Config::get('development')) {
         error_reporting(E_ALL | E_STRICT);
     }
     Mail::configure(Config::get('mail'));
     $request = null;
     $response = null;
     try {
         $request = new Request(Config::get('root'));
         // redirects the execution to a controller
         // according to the request parameters
         $response = new Response($request, Config::get('routes'), Config::get('cogs'));
         $controller = Controller::factory($request, $response, Config::get('database'));
         Widget::controller($controller);
         // allow widgets to access controller
         $controller->setDecorator(Config::get('templates/default'));
         $controller->run();
     } catch (Error $e) {
         $e->handle($request, $response, Config::get('templates/error'));
     } catch (Exception $e) {
         //TODO: handle everything else
         echo "An unexpected error occured!<br><br>";
         echo "{$e->getMessage()}<br>";
         var_dump(nl2br($e->getTraceAsString()));
     }
 }
Esempio n. 2
0
function widget($cog_dashed, $widget_dashed, $params = array())
{
    $widget = Widget::factory($cog_dashed, $widget_dashed, $params);
    return $widget->render();
}