コード例 #1
0
ファイル: Xajax.php プロジェクト: lagdo/xajax-core
 /**
  * Register request handlers, including functions, callable objects and events.
  *
  * New plugins can be added that support additional registration methods and request processors.
  * 
  *
  * @param string    $sType            The type of request handler being registered
  *        Options include:
  *        - Xajax::USER_FUNCTION: a function declared at global scope
  *        - Xajax::CALLABLE_OBJECT: an object who's methods are to be registered
  *        - Xajax::BROWSER_EVENT: an event which will cause zero or more event handlers to be called
  *        - Xajax::EVENT_HANDLER: register an event handler function.
  * @param mixed        $sFunction | $objObject | $sEvent
  *        When registering a function, this is the name of the function
  *        When registering a callable object, this is the object being registered
  *        When registering an event or event handler, this is the name of the event
  * @param mixed        $sIncludeFile | $aCallOptions | $sEventHandler
  *        When registering a function, this is the (optional) include file
  *        When registering a callable object, this is an (optional) array
  *             of call options for the functions being registered
  *        When registering an event handler, this is the name of the function
  *
  * @return mixed
  */
 public function register($sType, $mArg)
 {
     $aArgs = func_get_args();
     $nArgs = func_num_args();
     if (self::PROCESSING_EVENT == $aArgs[0]) {
         if ($nArgs > 2) {
             $sEvent = $aArgs[1];
             $xUserFunction = $aArgs[2];
             if (!is_a($xUserFunction, 'Request\\Support\\UserFunction')) {
                 $xUserFunction = new Request\Support\UserFunction($xUserFunction);
             }
             $this->aProcessingEvents[$sEvent] = $xUserFunction;
             return true;
         } else {
             // Todo: return error
         }
     }
     return $this->xPluginManager->register($aArgs);
 }