/**
  * {@inheritDoc}
  */
 public function deserialize($data)
 {
     if ($this->objectMapper) {
         $this->objectMapper->map($data);
     }
     return $this->serializer->unserialize($data);
 }
 /**
  * Test unserialize with recursion
  *
  * @return void
  */
 public function testUnserializeRecursion()
 {
     $serialized = '{"@type":"stdClass","c2":{"@type":"stdClass","c3":{"@type":"stdClass","c1":{"@type":"@0"},"ok":true}},"something":"ok"}';
     $obj = $this->serializer->unserialize($serialized);
     $this->assertTrue($obj->c2->c3->ok);
     $this->assertSame($obj, $obj->c2->c3->c1);
     $this->assertNotSame($obj, $obj->c2);
     $serialized = '{"@type":"stdClass","c2":{"@type":"stdClass","c3":{"@type":"stdClass","c1":{"@type":"@0"},"c2":{"@type":"@1"},"c3":{"@type":"@2"}},"c3_copy":{"@type":"@2"}}}';
     $obj = $this->serializer->unserialize($serialized);
     $this->assertSame($obj, $obj->c2->c3->c1);
     $this->assertSame($obj->c2, $obj->c2->c3->c2);
     $this->assertSame($obj->c2->c3, $obj->c2->c3->c3);
     $this->assertSame($obj->c2->c3_copy, $obj->c2->c3);
 }
示例#3
0
 /**
  * Convert the serialized array into an object
  *
  * @param aray $value
  * @return object
  * @throws Zumba\Exception\JsonSerializerException
  */
 protected function unserializeObject($value)
 {
     $className = $value[static::CLASS_IDENTIFIER_KEY];
     $obj = false;
     if ($className == 'MongoDate') {
         $obj = new \MongoDate($value['sec'], $value['usec']);
     } elseif ($className == 'MongoId') {
         $obj = new \MongoId($value['$id']);
     }
     if ($obj !== false) {
         $this->objectMapping[$this->objectMappingIndex++] = $obj;
         return $obj;
     }
     return parent::unserializeObject($value);
 }
 /**
  * @param ResponseInterface $response
  * @param JsonResult $jsonResult
  * @return ResponseInterface
  */
 private function modifyResponseForJsonResult(ResponseInterface $response, JsonResult $jsonResult)
 {
     $json = $this->jsonSerializer->serialize($jsonResult->getData());
     $stream = \GuzzleHttp\Psr7\stream_for($json);
     return $response->withHeader('Content-Type', 'application/json')->withBody($stream);
 }
示例#5
0
 protected function __store($id, &$value, $ttl)
 {
     $this->engine->save($id, $this->serializer->serialize($value), $ttl);
 }
示例#6
0
 public function updateBeneficiaryEvaluation($evaluation)
 {
     $data = -1;
     try {
         // -- Find data
         $serializer = new \Zumba\Util\JsonSerializer();
         $evaluationStr = $serializer->serialize($evaluation, false);
         $request = $this->client->post('evaluations', array(), $evaluationStr);
         $response = $request->send()->json();
         if (StatusConstants::OK == $response['status']) {
             if (!array_key_exists('data', $response)) {
                 return $data;
             }
             $data = $response['data'];
         } else {
             throw new \Exception($response['message'], StatusConstants::toCode($response['status']));
         }
     } catch (\Exception $e) {
         throw new \Exception('Erreur lors de l\'appel au P4S : updateBeneficiaryEvaluation()', StatusConstants::toCode(StatusConstants::UNKNOWN_ERROR), $e);
     }
     return $data;
 }