/** * Get value at the given path in JSON. * * @param string $path * * @return mixed */ private function getValueAtPath($path) { $content = $this->restContext->getMink()->getSession()->getDriver()->getContent(); if (null === ($decoded = json_decode($content, true))) { throw new \RuntimeException('JSON response seems to be invalid'); } $accessor = PropertyAccess::createPropertyAccessor(); return $accessor->getValue($decoded, $path); }
/** * Maps an exception * * @param lang.Throwable t * @param webservices.rest.srv.RestContext ctx * @return webservices.rest.srv.Response */ public function asResponse($t, RestContext $ctx) { return Response::error($this->statusCode)->withPayload($ctx->marshal(new \webservices\rest\Payload($t))); }