protected function _handleRequestGroup(Conn $from, $reqsData)
 {
     $responses = array();
     foreach ($reqsData as $reqData) {
         $responses[] = $this->_handleRequest($from, $reqData);
     }
     $resp = new ApiGroupResponse();
     $resp->setResponses($responses);
     return $resp;
 }
Example #2
0
 protected function executeApiCallGroup($conn, $req)
 {
     /*$request = new HTTPServerRequest($conn, $req);
     		$response = new HTTPServerResponse($conn);
     
     		$apiGroupCall = new ApiGroup;
     		$apiGroupCall->emulate($req->getPostFields()->getAll(), $request, $response);
     		$apiGroupCall->run();
     
     		return $apiGroupCall->httpResponse();*/
     $fields = $req->getPostFields()->getAll();
     if (!isset($fields['data'])) {
         $fields['data'] = array();
     }
     $reqsData = json_decode($fields['data'], true);
     $responses = array();
     foreach ($reqsData as $reqData) {
         $subreq = clone $req;
         foreach ($subreq->getPostFields() as $name => $value) {
             $subreq->removePostField($name);
         }
         $subreq->addPostFields($reqData);
         $responses[] = $this->executeApiCall($conn, $subreq)->content();
     }
     $resCtn = new ApiGroupResponse();
     $resCtn->setResponses($responses);
     $res = $this->getResponse($conn, $req);
     $res->addHeader('Content-Type: application/json');
     $res->setContent($resCtn);
     return $res;
 }