/** * @param Request $request * @return string */ public function encodeRequest(Request $request) { $closure = $request->getClosure(); $serialized = $this->serializer->serialize($closure); $request = new Request($serialized); return $this->encodeMessage($request); }
/** * Parse the data to be json encoded * * @param mixed $value * @return mixed * @throws JsonSerializerException */ protected function serializeData($value) { if (is_scalar($value) || $value === null) { if (!$this->preserveZeroFractionSupport && is_float($value) && ctype_digit((string) $value)) { // Because the PHP bug #50224, the float numbers with no // precision numbers are converted to integers when encoded $value = static::FLOAT_ADAPTER . '(' . $value . '.0)'; } return $value; } if (is_resource($value)) { throw new JsonSerializerException('Resource is not supported in JsonSerializer'); } if (is_array($value)) { return array_map(array($this, __FUNCTION__), $value); } if ($value instanceof \Closure) { if (!$this->closureSerializer) { throw new JsonSerializerException('Closure serializer not given. Unable to serialize closure.'); } return array(static::CLOSURE_IDENTIFIER_KEY => true, 'value' => $this->closureSerializer->serialize($value)); } return $this->serializeObject($value); }
/** * @return mixed */ public function getData() { return $this->serializer->serialize($this->closure); }