public function handleMultiRequest()
 {
     $listOfRequests = array();
     $results = array();
     $found = true;
     $i = 1;
     while ($found) {
         $currentService = isset($this->params[$i . ":service"]) ? $this->params[$i . ":service"] : null;
         $currentAction = isset($this->params[$i . ":action"]) ? $this->params[$i . ":action"] : null;
         $found = $currentAction && $currentService;
         if ($found) {
             $listOfRequests[$i]["service"] = $currentService;
             $listOfRequests[$i]["action"] = $currentAction;
             // find all the parameters for this request
             foreach ($this->params as $key => $val) {
                 // the key "1:myparam" mean that we should input value of this key to request "1", for param "myparam"
                 $keyArray = explode(":", $key);
                 if ($keyArray[0] == $i) {
                     array_shift($keyArray);
                     // remove the request number
                     $requestKey = implode(":", $keyArray);
                     /* remarked by Dor - 13/10/2010
                         * There is no need to remove service and action from the params in case of multirequest
                         * while they are needed in KalturaResponseCacher
                         
                        if (in_array($requestKey, array("service", "action"))) // don't add service name and action name to the params
                            continue;
                        
                        */
                     $listOfRequests[$i]["params"][$requestKey] = $val;
                     // store the param
                 }
             }
             // clientTag param might be used in KalturaResponseCacher
             if (isset($this->params['clientTag']) && !isset($listOfRequests[$i]["params"]['clientTag'])) {
                 $listOfRequests[$i]["params"]['clientTag'] = $this->params['clientTag'];
             }
             // if ks is not set for a specific request, copy the ks from the top params
             $currentKs = isset($listOfRequests[$i]["params"]["ks"]) ? $listOfRequests[$i]["params"]["ks"] : null;
             if (!$currentKs) {
                 $mainKs = isset($this->params["ks"]) ? $this->params["ks"] : null;
                 if ($mainKs) {
                     $listOfRequests[$i]["params"]["ks"] = $mainKs;
                 }
             }
             $currentPartner = isset($listOfRequests[$i]["params"]["partnerId"]) ? $listOfRequests[$i]["params"]["partnerId"] : null;
             if (!$currentPartner) {
                 $mainPartner = isset($this->params["partnerId"]) ? $this->params["partnerId"] : null;
                 if ($mainPartner) {
                     $listOfRequests[$i]["params"]["partnerId"] = $mainPartner;
                 }
             }
             $i++;
         } else {
             // will break the loop
         }
     }
     $i = 1;
     foreach ($listOfRequests as $currentRequest) {
         $currentService = $currentRequest["service"];
         $currentAction = $currentRequest["action"];
         $currentParams = $currentRequest["params"];
         // check if we need to replace params with prev results
         foreach ($currentParams as $key => &$val) {
             $matches = array();
             // keywords: multirequest, result, depend, pass
             // figuring out if requested params should be extracted from previous result
             // example: if you want to use KalturaPlaylist->playlistContent result from the first request
             // in your second request, the second request will contain the following value:
             // {1:result:playlistContent}
             if (preg_match('/\\{([0-9]*)\\:result\\:?(.*)?\\}/', $val, $matches)) {
                 $resultIndex = $matches[1];
                 $resultKey = $matches[2];
                 if (count($results) >= $resultIndex) {
                     if (strlen(trim($resultKey)) > 0) {
                         $resultPathArray = explode(":", $resultKey);
                     } else {
                         $resultPathArray = array();
                     }
                     $val = $this->getValueFromObject($results[$resultIndex], $resultPathArray);
                 }
             }
         }
         try {
             // cached parameters should be different when the request is part of a multirequest
             // as part of multirequest - the cached data is a serialized php object
             // when not part of multirequest - the cached data is the actual response
             $currentParams['multirequest'] = true;
             unset($currentParams['format']);
             $cache = new KalturaResponseCacher($currentParams);
             if (!isset($currentParams['ks']) && kCurrentContext::$ks) {
                 $cache->setKS(kCurrentContext::$ks);
             }
             $cachedResult = $cache->checkCache('X-Kaltura-Part-Of-MultiRequest');
             if ($cachedResult) {
                 $currentResult = unserialize($cachedResult);
             } else {
                 $currentResult = $this->dispatcher->dispatch($currentService, $currentAction, $currentParams);
                 // store serialized resposne in cache
                 $cache->storeCache(serialize($currentResult));
             }
         } catch (Exception $ex) {
             $currentResult = $this->getExceptionObject($ex);
             KalturaResponseCacher::disableCache();
         }
         $results[$i] = $currentResult;
         $i++;
     }
     return $results;
 }