/** * {@inheritDoc} */ public function deserialize($data) { if ($this->objectMapper) { $this->objectMapper->map($data); } return $this->serializer->unserialize($data); }
protected function __retrieve($id) { $content = $this->engine->fetch($id); if (false !== $content) { $content = $this->serializer->unserialize($content); } return $content; }
/** * 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); }