コード例 #1
0
ファイル: Gateway.php プロジェクト: xamiro-dev/xamiro
 /**
  * run gateway validating all options and handle request by server first by calling server setup method
  * then handle and finally tearing down the server instance. nothing will happen unless this function is called!
  *
  * @error 14016
  * @return void
  */
 public final function run()
 {
     xapp_debug('rpc gateway running', 'rpc');
     xapp_event('xapp.rpc.gateway.run', array(&$this));
     $this->server()->setup();
     if ($this->server()->hasCalls()) {
         if (xapp_get_option(self::VALIDATE, $this)) {
             foreach (xapp_get_options($this) as $k => $v) {
                 $this->validate($k, $v);
             }
         }
     }
     $this->server()->handle();
     $this->server()->teardown();
     xapp_debug('rpc gateway shutting down', 'rpc');
 }
コード例 #2
0
ファイル: defines.php プロジェクト: xamiro-dev/xamiro
 /**
  * @param $operation
  * @param string $suffix
  * @param $args
  * @param null $callee
  */
 function xcom_event($operation, $suffix = '', $args, $callee = null)
 {
     if ($callee !== null && $args !== null) {
         $args[XAPP_EVENT_KEY_CALLEE] = $callee;
     }
     xapp_event(XAPP_EVENT_PREFIX . $suffix . $operation, array($args));
 }
コード例 #3
0
ファイル: Server.php プロジェクト: xamiro-dev/xamiro
 /**
  * server teardown method will shutdown concrete server implementation and call post
  * service handler after successful shutdown. this method also fires teardown event after response has been flushed
  * by calling xapp event with event name xapp.rpc.server.teardown and also will look for "onTeardown" method in
  * called class and pass server instance if found
  *
  * @error 14219
  * @return void
  */
 public final function teardown()
 {
     xapp_event('xapp.rpc.server.teardown', array(&$this));
     if ($this->hasClass() && method_exists($this->getClass(), 'onTeardown')) {
         $this->getClass()->onTeardown($this);
     }
     $this->shutdown();
     $this->postHandle();
     exit;
 }
コード例 #4
0
ファイル: Response.php プロジェクト: xamiro-dev/xamiro
 /**
  * flushes headers and body. nothing will happen unless this method is called
  *
  * @error 14510
  * @return void
  */
 public final function flush()
 {
     xapp_event('xapp.rpc.response.flush', array(&$this));
     if (empty($this->_body) && !empty($this->_data)) {
         $this->body($this->data());
     }
     $this->flushHeader();
     $this->flushBody();
 }
コード例 #5
0
ファイル: core.php プロジェクト: xamiro-dev/xamiro
 /**
  * xapp error shortcut function used system wide to redirect errors back to xapp base class if xapp base class is used.
  * this function can be easily overwritten to handle errors thrown by exceptions and internal php errors channeled
  * through xapps internal error handler defined in XAPP_CONF_HANDLE_ERROR. use the the this function in all derived
  * exception classes inheriting from phps native ErrorException class in constructor - see Xapp_Error for example. when
  * implementing your own error handler you can bounce back your errors to this function or overwrite it. if xapp base
  * class is not used with direct error to default error handling defined either via phps set_error_handler function
  * or error_log function and triggered by phps trigger_error function. this functions expects exception as well as
  * errors passed as it there where an exception but only for logging purpose or even act as set_error_handler if needed.
  * when redirecting all errors to console you must load and enable Xapp_Console by defining an external console driver
  * like "firephp" and define XAPP_CONF_HANDLE_ERROR with value "console".
  *
  * overwrite like:
  * <code>
  *      function xapp_error($e, $c = 0, $s = 0, $f = null, $l = null)
  *      {
  *          //your custom code here
  *      }
  * </code>
  *
  * @param   string|Exception|Xapp_Error|array $e expects either string error message, instance of Exception or array
  *          return from phps native function error_get_last
  * @param   int $c expects optional error code
  * @param   int $s expects optional severity
  * @param   null|string $f expects the file where error occurred
  * @param   null|int $l expects the line where error occurred
  * @return  boolean|Xapp_Error returns Xapp_Error instance or false as deault
  */
 function xapp_error($e, $c = 0, $s = XAPP_ERROR_ERROR, $f = null, $l = null)
 {
     if (xapped()) {
         xapp_event('xapp.error', array($e));
         //redirect all errors to console
         if (xapped('Xapp_Console') && (bool) xapp_conf(XAPP_CONF_CONSOLE) && strtolower((string) xapp_conf(XAPP_CONF_HANDLE_ERROR) === 'console')) {
             if ($e instanceof Exception) {
                 xapp_console($e, $e->getMessage(), 'error');
             } else {
                 if (is_array($e) && isset($e['message'])) {
                     xapp_console($e, $e['message'], 'error');
                 } else {
                     $std = new stdClass();
                     $std->message = (string) $e;
                     $std->code = (int) $c;
                     $std->severity = (int) $s;
                     $std->file = (string) $f;
                     $std->line = (int) $l;
                     xapp_console($std, $std->message, 'error');
                 }
             }
             //redirect all error to xapp error handling
         } else {
             if ($e instanceof Xapp_Error) {
                 //do nothing because all has been done already since instance of Xapp_Error can only exists after constructor has
                 //been called and with calling parent constructor and stacking the error all has been done!
             } else {
                 if ($e instanceof Exception) {
                     return Xapp::e($e, (int) $c, (int) $s, $f, $l);
                 } else {
                     if (is_array($e) && isset($e['message'])) {
                         return Xapp::e($e['message'], (int) $e['type'], XAPP_ERROR_ERROR, $e['file'], $e['line']);
                     } else {
                         return Xapp::e((string) $e, (int) $c, (int) $s, $f, $l);
                     }
                 }
             }
         }
     } else {
         xapp_profile('error', $e);
         trigger_error((string) $e, E_USER_ERROR);
     }
     return false;
 }