/**
  * 
  *
  * @return MHTTPRequest
  */
 public static function request()
 {
     if (!MHTTPRequest::$request) {
         if (isRunningInSimulatedRequestMode()) {
             MHTTPRequest::$request = new MHTTPRequest(simulatedRequestFileName(), simulatedRequestName());
         } else {
             MHTTPRequest::$request = new MHTTPRequest();
         }
     }
     return MHTTPRequest::$request;
 }
 /**
  * Returns a boolean which indicates whether or not this application was called from
  * the command line, or whether it is being run as a result of a request to the
  * server.
  *
  * @return bool Returns true if the application is being run from the command line.
  * false otherwise.
  */
 public function isRunningFromCommandLine()
 {
     if (isRunningFromCommandLine() && !isRunningInSimulatedRequestMode()) {
         return true;
     }
     return false;
 }
Example #3
0
/**
 * @internal
 *
 * Mango Framework uncaught exception handler
 *
 * Default Exception handler for mango. This gets called by the system
 * every time there is an uncaught exception thrown.
 *
 * @param Exception	$exception	The exception thrown
 *
 * @return void
 */
function mango_exception_handler($exception)
{
    if (!MAppDelegate()->didRecoverFromUncaughtException($exception)) {
        logException($exception);
        if (!isRunningFromCommandLine() || isRunningInSimulatedRequestMode()) {
            $response = new MHTTPViewControllerResponse(new MErrorViewController(MHTTPResponse::RESPONSE_INTERNAL_SERVER_ERROR, N(MHTTPResponse::RESPONSE_INTERNAL_SERVER_ERROR), S("Internal Server Error"), S("Sorry but the page you are looking for could not be loaded due to an internal server error")));
            $response->setCode(MHTTPResponse::RESPONSE_INTERNAL_SERVER_ERROR);
            MDie($response);
        } else {
            MDie(null, 1);
        }
    }
}
Example #4
0
/**
 * @internal
 *
 * Returns the name of the request that should be used
 *
 * @see isRunningInSimulaterRequestMode()
 * @see "--simulate-request"
 *
 * @return string The name of the request that should be used
 */
function simulatedRequestName()
{
    global $argv;
    if (isRunningFromCommandLine() && isRunningInSimulatedRequestMode()) {
        if (isset($argv[3])) {
            return $argv[3];
        }
    }
    return null;
}