xajaxCallableObject::generateRequests PHP Method

generateRequests() public method

Produces an array of objects, one for each method exposed by this callable object. sXajaxPrefix - (string): The prefix to be prepended to the javascript function names; this will correspond to the name used for the function stubs that are generated by the generateClientScript> call.
public generateRequests ( $sXajaxPrefix )
    public function generateRequests($sXajaxPrefix)
    {
        $aRequests = array();
        $sClass = get_class($this->obj);
        foreach (get_class_methods($this->obj) as $sMethodName) {
            $bInclude = true;
            // exclude magic __call, __construct, __destruct methods
            if (2 < strlen($sMethodName)) {
                if ("__" == substr($sMethodName, 0, 2)) {
                    $bInclude = false;
                }
            }
            // exclude constructor
            if ($sClass == $sMethodName) {
                $bInclude = false;
            }
            if ($bInclude) {
                $aRequests[strtolower($sMethodName)] = new xajaxRequest("{$sXajaxPrefix}{$sClass}.{$sMethodName}");
            }
        }
        return $aRequests;
    }

Usage Example

 public function register($aArgs)
 {
     if (1 < count($aArgs)) {
         $sType = $aArgs[0];
         if (XAJAX_CALLABLE_OBJECT == $sType) {
             $xco = $aArgs[1];
             //SkipDebug
             if (false === is_object($xco)) {
                 trigger_error("To register a callable object, please provide an instance of the desired class.", E_USER_WARNING);
                 return false;
             }
             //EndSkipDebug
             if (false === $xco instanceof xajaxCallableObject) {
                 $xco = new xajaxCallableObject($xco);
             }
             if (2 < count($aArgs)) {
                 if (is_array($aArgs[2])) {
                     foreach ($aArgs[2] as $sKey => $aValue) {
                         foreach ($aValue as $sName => $sValue) {
                             $xco->configure($sKey, $sName, $sValue);
                         }
                     }
                 }
             }
             $this->aCallableObjects[] = $xco;
             return $xco->generateRequests($this->sXajaxPrefix);
         }
     }
     return false;
 }
All Usage Examples Of xajaxCallableObject::generateRequests