/** * @param $path * @return \Timiki\Bundle\RpcServerBundle\Server\Handler * @throws \Timiki\Bundle\RpcServerBundle\Server\Exceptions\InvalidMappingException */ public static function getHandler($path = null) { $mapper = self::getMapper($path); $handler = new Handler(); $handler->setMapper($mapper); return $handler; }
/** * Handle json request. * * @param JsonRequest|JsonRequest[] $jsonRequest * @return JsonResponse|JsonResponse[]|null */ public function handleJsonRequest(JsonRequest $jsonRequest) { // Fix session block if ($this->container) { $this->container->get('session')->save(); } try { $jsonResponse = $this->client->execute($jsonRequest); } catch (\Exception $e) { if (is_array($jsonRequest)) { $jsonResponse = []; foreach ($jsonRequest as $id => $request) { $jsonResponse[$id] = $this->handler->createJsonResponseFromException(new Exceptions\ProxyException($e->getMessage(), $request->getId()), $request); } } else { $jsonResponse = $this->handler->createJsonResponseFromException(new Exceptions\ProxyException($e->getMessage(), $jsonRequest->getId()), $jsonRequest); } } // Restore session if ($this->container) { $this->container->get('session')->save(); } return $jsonResponse; }