private function addFiltersParameter() { $filters = new Gpf_Rpc_Array(); foreach ($this->filters as $filter) { $filters->add($filter); } return $filters; }
public static function getEncodedCountries() { $countries = self::createCountries(); $output = new Gpf_Rpc_Array(); $output->add(new Gpf_Rpc_Array(array('code', 'name'))); foreach ($countries as $key => $country) { $output->add(new Gpf_Rpc_Array(array($key, $country))); } return $output; }
public function send() { $request = new Gpf_Rpc_Request($this->serverClassName, Gpf_Rpc_Server::RUN_METHOD); if ($this->useNewStyleRequestsEncoding) { $request->addParam(Gpf_Rpc_Server::REQUESTS_SHORT, $this->requests); } else { $request->addParam(Gpf_Rpc_Server::REQUESTS, $this->requests); } if ($this->sessionId != null) { $request->addParam("S", $this->sessionId); } $requestBody = $this->json->encodeResponse($request); $responseText = $this->sendRequest($requestBody); if ($this->debugRequests) { echo "REQUEST: " . $requestBody . "<br/>"; echo "RESPONSE: " . $responseText . "<br/><br/>"; } $responseArray = $this->json->decode($responseText); if (!is_array($responseArray)) { throw new Gpf_Exception("Response decoding failed: not array. Received text: {$responseText}"); } if (count($responseArray) != $this->requests->getCount()) { throw new Gpf_Exception("Response decoding failed: Number of responses is not same as number of requests"); } $exception = false; foreach ($responseArray as $index => $response) { if (is_object($response) && isset($response->e)) { $exception = true; $this->requests->get($index)->setResponseError($response->e); } else { $this->requests->get($index)->setResponse($response); } } if ($exception) { $messages = ''; foreach ($this->requests as $request) { $messages .= $request->getResponseError() . "|"; } } $this->requests = new Gpf_Rpc_Array(); if ($exception) { throw new Gpf_Rpc_ExecutionException($messages); } }
/** * Executes multi request * * @service * @anonym * @return Gpf_Rpc_Serializable */ public function run(Gpf_Rpc_Params $params) { $requestArray = $params->get(self::REQUESTS); if ($requestArray === null) { $requestArray = $params->get(self::REQUESTS_SHORT); } $response = new Gpf_Rpc_Array(); foreach ($requestArray as $request) { $response->add($this->executeRequest(new Gpf_Rpc_Params($request))); } return $response; }
protected function getFiltersParameter() { $filters = new Gpf_Rpc_Array(); foreach ($this->filters as $filter) { $filters->add($filter); } return $filters; }