Exemplo n.º 1
0
 /**
 Get Singleton instance of this class
 */
 public static function getInstance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemplo n.º 2
0
 function __construct()
 {
     // Get the parameters from the request
     $this->fc = RequestMediator::getInstance();
     $this->pageState = $this->fc->getParams();
     // Start/Continue a session
     session_start();
     // Instantiate a view to be used by the controller
     $this->view = new View();
     $this->view->session = $_SESSION;
     $this->view->pageState = $this->pageState;
 }
Exemplo n.º 3
0
        // Controller not found, so show 404 page.
        $controller = new Site404Controller();
        $controller->get();
    }
}
function exceptionHandler($ex)
{
    $msg = '<h1>Exception not handled - caught by global handler</h1>';
    $msg .= '<strong>Message</strong>: <em>' . $ex->getMessage() . '</em><br/>';
    $msg .= '<strong>in</strong> ' . $ex->getFile() . ' <strong>Line</strong>: ' . $ex->getLine() . '<br/>';
    $msg .= '<strong>trace</strong>: <br/>';
    $i = 1;
    foreach ($ex->getTrace() as $trace) {
        $msg .= "[{$i}]";
        $msg .= ' ==> ' . $trace['file'] . ' Line: ' . $trace['line'] . '<br/>';
        $msg .= ' ======> ' . $trace['class'] . '::' . $trace['function'] . ' Args: ' . print_r($trace['args'], true) . '<br/>';
        $i++;
    }
    //	print_r($ex->getTrace());
    // For now, just print the message to the screen. For production, show a generic error screen and
    // log the details instead.
    print $msg;
    // TODO - send to framework error page
}
// Setup error reporting and handling of top-level exceptions
error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_exception_handler('exceptionHandler');
// Initialize the FrontController and route the request
$front = RequestMediator::getInstance();
$front->route();
print $front->getBody();